代码:
//万能主程序
#include<bits/stdc++.h>
//加载主程序
using namespace std;
int main(){
//创造三个int型变量 a=答案 b=输入的数 c=输入的次数
int a=5,b,c=0;
//输出:请输入1--100
cout<<"请输入1--100"<<endl;
//while循环
while(a!=b){
//输入猜的数字
cin>>b;
//判断答案对不对
if(b>a){
cout<<"大了!大了!"<<endl;
}else if(b<a){
cout<<"小了!小了!"<<endl;
}else{
cout<<"对!"<<endl;
break;
}
//增加输入的次数
c++;
}
//输出了多少次
cout<<"您输出了"<<c+1<<"次";
return 0;
}