#include<iostream>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
int s = rand()%100+1;
cout<<"生成了1-100的随机数"<<endl;
cout<<"来猜猜看吧"<<endl;
int c=0;
while (true)
{
int n;
cin>>n;
c++;
if(n>s)
{
cout<<"你猜的太大了"<<"一共猜了"<<c<<"次"<<endl;
}
if(n<s)
{
cout<<"你猜的太小了"<<"一共猜了"<<c<<"次"<<endl;
}
if(n==s)
{
cout<<"你猜的太对了"<<"一共猜了"<<c<<"次"<<endl;
}
}
cout<<c;
return 0;
}
好玩的的东西
最新推荐文章于 2025-05-05 14:12:43 发布