这是我的第二个小游戏,很简单,不,应该是特别简单。
猜猜这是什么游戏?对了,就是猜数字。
这是我的第一篇
在这里插入图片描述

是不是很简单

#include<iostream>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
int main(){
	srand(time(0));
	int n=rand()%1000;
	int c=-1,ans=0;
	cout<<"你要猜的数字为:***"<<endl<<endl; 
	while(c!=n){
		cout<<"你猜的数是:";
		cin>>c;
		ans++;
		if(c>n){
			Sleep(500); 
			cout<<"大了!"<<endl<<endl; 
		} else if(c<n){
			Sleep(500);
			cout<<"小了!"<<endl<<endl;
		}
	}
	cout<<"恭喜猜中!!!"<<endl<<"共用了"<<ans<<"次!!!"<<endl; 
	system("pause");
	return 0;
}


我的洛谷团队:https://www.luogu.com.cn/team/42465

更多推荐