#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(int argc, char** argv) { int x; srand(time(0)); do{ int num=rand()%100; cout<<"请输入一个数字,我看康康对不对,当前是第"<<x<<"次"<<endl; int a; cin>>a; if(a==num){ cout<<"相等"<<endl; break; }else if(a>num){ cout<<"大了"; }else{ cout<<"小了"; } x++; }while(true); cout<<"你真棒,只用了"<<x<<"次"<<endl; return 0; }
标签:二分,num,cout,--,int,查找,include From: https://www.cnblogs.com/fushuxuan/p/17255075.html