chat.h
来自「Basicaly,a chatterbot is a computer prog」· C头文件 代码 · 共 40 行
H
40 行
// Program Name: chatterbot1
// Description: this is a very basic example of a chatterbot program
//
// Author: Gonzales Cenelia
//
#include <iostream>
#include <string>
#include <ctime>
int main()
{
std::string Response[] = {
"I HEARD YOU!",
"SO,YOU ARE TALKING TO ME.",
"CONTINUE,I'M LISTENING.",
"VERY INTERESTING CONVERSATION.",
"TELL ME MORE..."
};
srand((unsigned) time(NULL));
std::string sInput = "";
std::string sResponse = "";
while(1) {
std::cout << ">";
std::getline(std::cin, sInput);
int nSelection = rand() % 5;
sResponse = Response[nSelection];
if(sInput == "bye") {
std::cout << "IT WAS NICE TALKING TO YOU USER, SEE YOU NEXT TIME!" << std::endl;
break;
}
std::cout << sResponse << std::endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?