各位,我正左個c++的估數字game,但係估唔中後唔識叫人重新輸入,應該點攪?
my code:
#include <cstdlib>
#include <iostream>
#include <time.h>
using namespace std;
#define START 1
#define END 100
int main(){
int ans;
int guesstime;
int num;
srand( (unsigned)time(NULL) );
ans = rand() % 100 + 1;
guesstime = 0;
cout << "Please guess a number: \n";
cin >> num;
if (num == ans){
cout << "Congratulations! you use " << guesstime << " time to win it!! \n\n";
}
else if (num > ans){
cout << "Sorry, the number you guess is too large. \n\n" << endl;
}
else if (num < ans){
cout << "Sorry, the number you guess is too small. \n\n" << endl;
}
system("PAUSE");
return 0;
}