#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int generateRandomNumber(int min, int max,int time) {
srand((unsigned)time(NULL));
int randomNumber = rand() % (max - min + 1) + min;
return randomNumber;
}
int main(){
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE)return GetLastError();
DWORD dwMode = 0;
if (!GetConsoleMode(hOut, &dwMode))return GetLastError();
dwMode |= 0x0004;
if (!SetConsoleMode(hOut, dwMode))return GetLastError();
wprintf(L"\x1b[38;2;%d;%d;%dmrgb测试\n",102,204,255);
//上方为RGB代码 喵喵(>^ω^<)喵
int a,b;//代表最大最小数
long long int ans;
cout<<"请输入最小和最大的数:";
cin>>a>>b;
ans=generateRandomNumber(a,b);
cout<<ans<<endl;
int c;//用户输入
while(1){
cin>>c;
if(ans==c){
cout<<"猜对了";
Sleep(2000);
break;
}else if(c>ans){
cout<<"猜大了";
Sleep(2000);
cout<<"请输入要猜的数字:";
}else if(c<ans){
cout<<"猜小了";
Sleep(2000);
cout<<"请输入要猜的数字:";
}else{
cout<<"不要输入范围外的数";
Sleep(2000);
cout<<"请输入要猜的数字:";
}
}
return 0;
}
玄学bug 离谱