Code of artificial mental retardation valued at 100 million (C++)

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:
Insert picture description here
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

Guess you like

Origin blog.csdn.net/weixin_45711556/article/details/109068630