直接上代码!!!
// By School //
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
void cls() {
system("cls");
}
int power(int n) {
long long s = 1,i = 0;
while(s < n) {
s *= 2;
i++;
}
return i;
}
void ccc(string s) {
for(int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(25);
}
cout << "\n";
}
void c_slow(string s) {
for(int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(444);
}
cout << "\n";
}
int main() {
cls();
ccc("输入范围 输入0关闭");
int n;
cin >> n;
if(n == 0)
return 0;
cls();
printf("范围为 1 ~ %d\n",n);
long long s = power(n);
long long ans = rand() % n + 1;
printf("你最少要猜%d次,更少算我输!\n",s);
ccc("猜吧");
long long sum = 1;
while(1) {
int x;
cin >> x;
if(x > ans) {
ccc("大了");
sum++;
}
else if(x < ans) {
ccc("小了");
sum++;
}
else {
cls();
c_slow("Yes!");
printf("你用了%d次!",sum);
break;
}
}
return 0;
}