本文主要是介绍估值一亿的人工智障代码(C++),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
真 · 人工智障(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;
}
运行效果:
我的博客即将同步至腾讯云+社区,邀请大家一同入驻:
https://cloud.tencent.com/developer/support-plan?invite_code=197e7c9rkiv72
这篇关于估值一亿的人工智障代码(C++)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!