#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int index=1; srand(time(0)); int num=rand()%100; do{ int n; cin>>n; if(n==num){ cout<<"对了"<<endl; break; } else if(n>num){ cout<<"大了"<<endl; } else { cout<<"小了"<<endl; } index++; }while(true); cout<<"用了"<<index<<"才打对"<<endl; return 0; }
标签:二分,std,num,int,查找,main From: https://www.cnblogs.com/hanxuyao/p/17255081.html