估值一亿的人工智障代码(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

猜你喜欢

转载自blog.csdn.net/weixin_45711556/article/details/109068630
今日推荐