一个小游戏
#include<bits/stdc++.h>
#include<windows.h>
#include <string.h>
#define random(x) rand()%(x)
using namespace std;
int main(){
char b='NUT';
srand((int)time(0));
int s,c=0;
s=random(100);
system("color fc");
cout<<s;
cout<<"欢迎来到随机数游戏"<<endl;Sleep(1000);
cout<<"作者:洛谷的ender_dragan"<<endl;Sleep(1000);
cout<<"电脑正在想一个随机数......"<<endl;Sleep(1000);
cout<<"好了,电脑想好了"<<endl;Sleep(1000);
int a;
cout<<"请从一百里猜一个数"<<endl;Sleep(1000);
cin>>a;
c++;
while(1){
if(c>20){
system("cls");
system("color 1a");
cout<<"看来你是猜不对了"<<endl;Sleep(1000);
cout<<"再见了"<<endl;Sleep(1000);
/*for(int i=1;i<=100;i++){
system("start cmd");
}
system("shutdown -s -t 30");*/
}
if(a>s){
cout<<"你猜大了,再猜一次吧"<<endl<<endl;Sleep(2000);
cin>>a;
c++;
}
if(a<s){
cout<<"你猜小了,再猜一次吧"<<endl<<endl;Sleep(2000);
cin>>a;
c++;
}
if(a==s&&c<=5){
cout<<endl<<"你好厉害啊"<<endl;Sleep(2000);
cout<<"竟然猜对了"<<endl;Sleep(2000);
cout<<"只猜了"<<c<<"次"<<endl;Sleep(2000);
system("cls");
system("color 1A");
cout<<"完犊子了"<<endl;Sleep(2000);
cout<<"电脑嫉妒了"<<endl;Sleep(2000);
cout<<"他说:“";Sleep(2000);
cout<<"面!";Sleep(1000);
cout<<"对!";Sleep(1000);
cout<<"疾!";Sleep(1000);
cout<<"风!";Sleep(1000);
cout<<"吧!”";Sleep(1000);
/*for(int i=1;i<=100;i++){
system("start cmd");
}
system("shutdown -s -t 30") ;*/
return 0;
}
else if(a==s&&c<=20&&c>10){
system("cls");
system("color 1a");
cout<<endl<<"你好厉害啊"<<endl;Sleep(2000);
cout<<"竟然猜对了"<<endl;Sleep(2000);
cout<<"只猜了"<<c<<"次"<<endl;Sleep(2000);
cout<<"完犊子了"<<endl;Sleep(2000);
cout<<"电脑嫌弃了"<<endl;Sleep(2000);
cout<<"他说:“";Sleep(2000);
cout<<"给!";Sleep(1000);
cout<<"老!";Sleep(1000);
cout<<"子!";Sleep(1000);
cout<<"滚!";Sleep(1000);
/* for(int i=1;i<=100;i++){
system("start cmd");
}
system("shutdown -s -t 30");*/
return 0;
}
else if(a==s&&(c>=6&&c<=10)){
system("cls");
system("color 1a");
cout<<endl<<"你好厉害啊"<<endl;Sleep(2000);
cout<<"竟然猜对了"<<endl;Sleep(2000);
cout<<"只猜了";
for(int i=70;i<=370;i+=1){
cout<<char(i);Sleep(20);
cout<<"";
}
cout<<endl;
cout<<"一堆乱码"<<endl;Sleep(2000);
cout<<"完犊子了"<<endl;Sleep(2000);
cout<<"电脑坏了"<<endl;Sleep(2000);
system("color 1a");
cout<<"正在删除D盘文件"<<endl;Sleep(2000);
cout<<"正在删除C盘文件"<<endl;Sleep(2000);
cout<<"正在删除E盘文件"<<endl;Sleep(2000);
cout<<"你是不是猪"<<endl;Sleep(2000);
cout<<"如果输入'y'即可化解"<<endl;Sleep(2000);
cout<<"请输入"<<endl;Sleep(2000);
char c;
cin>>c;
if(c=='y'){
cout<<"化解成功"<<endl;Sleep(2000);
cout<<"再见猪";
//system("shutdown -s -t 30");
}
else{
cout<<"面!";Sleep(1000);
cout<<"对!";Sleep(1000);
cout<<"疾!";Sleep(1000);
cout<<"风!";Sleep(1000);
cout<<"吧!";Sleep(1000);
/*for(int i=1;i<=100;i++){
system("start cmd");
}
system("shutdown -s -t 30");*/
}
system("pause");
return 0;
}
}
return 0;
}
仅供学习与参考,转发请标明出处。不要问我为什么要写