#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int max=100,min=0; string b; cout<<"请你想一个数1~100"<<endl; system("pause"); cout<<"这个数是:"<<(max-min)/2+min<<endl; for(int i=0;i<8;i++){ cin>>b; if(b=="大了"){ max=(max-min)/2+min; cout<<"这个数是:"<<(max-min)/2+min<<endl; }else if(b=="小了"){ min=(max-min)/2+min; cout<<"这个数是:"<<(max-min)/2+min<<endl; }else{ cout<<"nb"; break; } } return 0; }
标签:二分,cout,min,int,max,查找 From: https://www.cnblogs.com/hanxuyao/p/17464219.html