#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int index=1; srand(time(0)); int num=rand()%100; int a; do{ cout<<"这是第"<<index<<"次"<<endl; cin>>a; if(a==num){ cout<<"相等"<<endl; break; }else if(a>num){ cout<<"大了"<<endl; }else{ cout<<"小了"<<endl; } index++; }while(true); cout<<"用了"<<index<<"次"; return 0; }
标签:std,cout,int,num,随机数,include From: https://www.cnblogs.com/As10016/p/17255052.html