自编小游戏,欢迎私信或评论,提供建议、bug和不足之处。
游戏名解释:你(玩家)、我(电脑)。
后期更新:你想我猜1.1、你猜我猜1.2、二人转1.3。
代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
system("color E1");
int a,c,d=0;
string b;
srand(time(0));
c=rand()%100+1;
while(1){
cout<<" ======================================================================="<<endl;
cout<<" || ||"<<endl;
cout<<" || ||"<<endl;
cout<<" || 你 猜 我 想 ||"<<endl;
cout<<" || ||"<<endl;
cout<<" || ||"<<endl;
cout<<" ======================================================================="<<endl;
cout<<"======================================================================================================"<<endl;
cout<<setw(90)<<right<<"分数:"<<d<<endl;
cout<<"请输入一个数字:";
cin>>a;
b=(a==c)?"猜对了!":"猜错了";
cout<<b<<endl;
if(b=="猜对了!"&&a==c){
d++;
srand(time(0));
c=rand()%100+1;
}
if(b=="猜错了"&&a>c){
cout<<"大了"<<endl;
}
if(b=="猜错了"&&a<c){
cout<<"小了"<<endl;
}
system("Pause");
system("cls");
}
return 0;
}
时间是治疗心灵创伤的大师,但绝不是解决问题的高手。 6gn.