#include<bits/stdc++.h>
using namespace std;
int a[1001],i,j,n,n1,m,maxa,maxb,mina,minb;
int main(){
printf(" 猜数游戏");
cout<<endl;
cout<<"请输入一个数字,表示有几次机会"<<endl;
cin>>n1;
srand((unsigned)time(0));
cout<<"好的,请输入1-几的范围"<<endl;
cin>>m;
m=rand()%m+1;
cout<<"OK,请继续输入您猜的数"<<endl;
while(n!=m){
if(j<n1){
cin>>n;
if(n>m){
cout<<"大了"<<endl;
j++;
}else if(n<m){
cout<<"小了"<<endl;
j++;
}
}else if(n1==j){
cout<<"正确答案是"<<m<<endl;
cout<<"你失败了!";
return 0;
}
}
cout<<"你猜对惹";
return 0;
}
11-05
5542
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-08
1268
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-17
965
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-01
140
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-31
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交