C++人工智能01C版本

这次新增了个游戏功能

看代码

#include"bits/stdc++.h"
#include"Windows.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
bool memory[11]={false};
char z[1048576]={'`'};
void calculator(char b,double a,double c){
	if(b=='+') cout<<"\n"<<a+c;
	else if(b=='-') cout<<"\n"<<a-c;
	else if(b=='*') cout<<"\n"<<a*c;
	else if(b=='/') cout<<"\n"<<a/c;
	else cout<<"\n输入无效";
}
void chat(string l){
	if(l=="你好"){
		system("cls");
		cout<<"你好";
	}
	else if(l=="你好骚年"){
		system("cls");
		cout<<"你好,但我可不是什么骚年,我是人工智能QPBS01B!";
	}
	else if(l=="man"||l=="what can I say"||l=="manba out"||l=="man,what can I say"||l=="man,what can I say,manba out"){
		system("cls");
		cout<<"青春没有售价,扣1复活牢大!!!";
	}
	 else if(l=="我要上博客"){
		system("cls");
		cout<<"好的";
		system("start https://www.csdn.net/");
	}
	else if(l=="我想要算数"){
		system("cls");
		cout<<"好的";
		Sleep(1000); 
		double aa,cc;
		char bb;
		cout<<"\n请输入算式(a+b形式):";
		cin>>aa>>bb>>cc;
		calculator(bb,aa,cc);
	}
	else if(l=="我要记东西"){
		system("cls");
		cout<<"好的";
		Sleep(1000); 
		cout<<"\n请输入要记的东西(不超过1048576字):";
		cin>>z;
		int o=strlen(z);
		cout<<"\n还能记"<<1048576-o<<"个字";
		Sleep(5000);
	}
	else if(l=="我要玩游戏"||l=="我要玩小游戏"||l=="我还要玩"){
		system("cls");
		cout<<"好的";
		Sleep(1000); 
		system("cls");
		cout<<"1.石头剪刀布  2.猜数字  3.取火柴\n";
		int bianhao;
		cin>>bianhao;
		if(bianhao==1){ 
			srand(time(NULL));
			int stjdb=rand()%3+1;
			int player;
			cout<<"你出什么(输入1~3中任意一个数字,1是石头,2是剪刀,3是布)?\n";
			cin>>player;
			if(player==1){
				if(stjdb==1) cout<<"1 1平局!\n";
				if(stjdb==2) cout<<"2 1你赢了!\n";
				if(stjdb==3) cout<<"3 1你输了!\n";
			}
			else if(player==2){
				if(stjdb==1) cout<<"1 2你输了!\n";
				if(stjdb==2) cout<<"2 2平局!\n";
				if(stjdb==3) cout<<"3 2你赢了!\n";
			}
			else if(player==3){
				if(stjdb==1) cout<<"1 3你赢了!\n";
				if(stjdb==2) cout<<"2 3你输了!\n";
				if(stjdb==3) cout<<"3 3平局!\n";
			}
			else cout<<"输入错误!";
		}
		else if(bianhao==2){
			srand(time(0));
			int csz=rand()%1+100,player;
			cout<<"我想了一个1~100之间的数字,你猜猜是多少?\n";
			cin>>player;
			if(player==csz) cout<<"真厉害,你猜对了!\n";
			else cout<<"你再想想吧,猜错了!\n";
		}
		else if(bianhao==3){
			int huochai=15,compu,player;
			bool plawin=false;
			for(int i=0;huochai<=0;i++){
				cout<<"还有"<<huochai<<"根火柴\n";
				cout<<"一次可以取走3根火柴\n";
				cout<<"AI取火柴:\n";
				srand(time(0));
				compu=rand()%1+3;
				cout<<compu;
				if(huochai-compu<=0) plawin=false;
				huochai-=compu;
				cout<<"还有"<<huochai<<"根火柴\n";
				cout<<"一次可以取走3根火柴\n";
				cout<<"玩家取火柴\n:";
				cin>>player;
				if(huochai-player<=0) plawin=true;
				huochai-=player;
			}
			if(plawin==true) cout<<"你赢了!\n";
			else cout<<"你输了!\n";
		}
	}
	else if(l=="给我讲个笑话吧"){
		system("cls");
		cout<<"好的";
		Sleep(500);
		cout<<"\n我来讲个我的主人的老师的笑话吧";
		Sleep(500);
		cout<<"\n宋代诗人苏轼有个和尚朋友";
		Sleep(500);
		cout<<"\n一天他俩相见了";
		Sleep(500);
		cout<<"\n那个和尚说:“我今天看到你像一尊佛。”";
		Sleep(500);
		cout<<"\n苏轼说:“我今天看到你像一坨屎。”";
		Sleep(500);
		cout<<"\n苏轼回家后跟苏小妹说了这件事";
		Sleep(500);
		cout<<"\n苏小妹回答说:“一个人骂别人什么他的肚子里就装着什么”";
		Sleep(500);
	}
	else if(l=="你会什么"){
		system("cls"); 
		cout<<"这个问题问得好\n";
		Sleep(500);
		cout<<"我会跟你说话,帮你计算,帮你记事,但有些功能小主人还没给我开发";
	}
	else if(l=="我想要看看我记的东西"){
		system("cls"); 
		cout<<"好的\n";
		Sleep(500);
		for(int i=0;i<strlen(z);i++) cout<<z[i];
	}
	else if(l=="帮我查看一下电脑"){
		system("cls"); 
		Sleep(500);
		system("dir/s"); 
	}
	else if(l=="你的主人是谁"||l=="你的开发者是谁"){
		system("cls"); 
		cout<<"这个问题问得好\n";
		Sleep(500);
		cout<<"我的主人是奇葩博士小王同学";
	}
	else{
		system("cls");
		cout<<"抱歉,我暂时不会解答";
	}
} 
void CPU(){
	for(int i=1;i<=10;i++) memory[i]=true;
	while(1){
		string ll;
		cin>>ll;
		chat(ll);
	}	
}
int main(){
	cout<<"\n\n\n\n	奇葩博士--小王同学的人工智能QPBS01B\n\n\n                     作者:王大虫\n\n\n         人工智能QPBS01B体验服务(A键开始)";
	while(!KEY_DOWN(65));
	for(int i=1;i<=100;i++){
		system("cls");
		cout<<"%"<<i;
		for(int j=1;j<=i;j++) cout<<"▌"; 
	}
	system("cls");
	for(int i=0;i<3;i++){
		cout<<"正在开机.";
		Sleep(200);
		system("cls");
		cout<<"正在开机..";
		Sleep(200);
		system("cls");
		cout<<"正在开机...";
		Sleep(200);
		system("cls");
	}
	for(int i=1;i<=10;i++) memory[i]=true;
	while(1){
		system("cls");
		cout<<"我是人工智能QPBS01C\n";
		CPU(); 
	}
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值