#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main(int argc, char** argv) { /*int a,n; cout<<"抽奖程序"<<endl<<"请输入一个1-5的数"<<endl; cin>>n; srand(time(0)); a=rand()%5+1; if(n==a){ cout<<"恭喜你中奖了"; }else{ cout<<"抱歉你没中奖"<<endl; cout<<"答案是:"<<a<<endl; } system("pause");*/ /*int a,n,b; srand(time(0)); a=rand()%90+10; b=rand(); cout<<a<<'+'<<b<<'='; cin>>n; if(n>b)cout<<"对"; else cout<<"错";*/ int a,n; srand(time(0)); a=rand()%100+1; cin>>n; while(n!=a){ if(a>n){ cout<<"小了"; cin>>n; } if(n>a){ cout<<"大了"; cin>>n; } if(n==a){ cout<<"猜对了"; } } return 0; }
标签:std,rand,main,cout,int,大小,include From: https://www.cnblogs.com/w6826301/p/17487050.html