Really Artificial Intelligence (C++)
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
while (true) {
cout << "Q: ";
cin >> str;
cout << endl;
int pos1 = str.find("你");
if (pos1 != str.npos) str.replace(pos1, 2, "我");
int pos2 = str.find("是不是");
if (pos2 != str.npos) str.replace(pos2, 6, "是");
int pos3 = str.find("吗");
if (pos3 != str.npos) str.replace(pos3, 2, " ");
int pos4 = str.find("?");
if (pos4 != str.npos) str.replace(pos4, 2, "!");
cout << "A: " << str << endl << endl;
}
return 0;
}
Operational effect:
My blog will be synchronized to Tencent Cloud + community soon, and everyone is invited to join in:
https://cloud.tencent.com/developer/support-plan?invite_code=197e7c9rkiv72