#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int min = 1;
int max = 100;
int count = 0;
int randomint = min + (rand() % (int)(max - min + 1));
bool isCorrect = true;
while(!isCorrect){
int guess = 0;
cout << "What is your guess? " << endl;
cin >> guess;
if(guess < randomint){
cout << "Too low!" << endl;
count++;
} else if (guess > randomint){
cout << "Too high!" << endl;
count++;
} else{
cout << "Correct!" << endl;
cout << "Number of Guesses: " << count << endl;
isCorrect = true;
}
}
}
新的 C++ 编程。我无法用它来编译一个 IDEOne,因为它没有我运行这个程序所需的输入系统。我必须尽快提交这个课程,但考虑到我的较大磁盘(存储我所有软件的地方)昨晚已损坏。
我为这个问题的愚蠢道歉。