누군가이 "Random Guess My Number Game"에 대한 내 코드를 살펴볼 수 있는지 궁금합니다.C++ 완료 임의 번호 추측 내 번호 게임 둘러보기
여기에 모든 코드입니다 : 나에게 어떤 조언을 줄 수
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int PlayerNumber, x;
bool win = false;
long foo;
char milliongame;
int main(){
srand (time(NULL));
cout << "Guess your computers number." << endl << endl;
for (int level = 1, foo = 10; level<=10; level++, foo = foo*2){
switch (foo){
case 20:
foo = 25;
break;
case 200:
foo = 250;
break;
case 2000:
foo = 2500;
break;
}
win = false;
x = (rand()%foo + 1);
refresh:
cout << "level " << level << endl;
cout <<"Computers number is between 1 and "<< foo << endl;
cout << "Your number: "; cin >> PlayerNumber;
if (!cin || PlayerNumber > foo || PlayerNumber <= 0){
cout << "That's not a number between 1 and " << foo << " !" << endl;
PlayerNumber = 0;
system("pause");
system("cls");
goto refresh;
}
if (x > PlayerNumber)
cout << "Your number was lower than the computers." << endl;
if (x < PlayerNumber)
cout << "Your number was higher than the computers" << endl;
if (x == PlayerNumber){
cout << "You Won! \n\nThe computer's number was "<< x << endl; win = true;
}
cout << endl; system("pause");
system("cls");
if (win != true){
goto refresh;
}
}
cout << "You Beat the Game! \n\nDo You Dare Play for a Million? \n[y/n]: "; cin >> milliongame;
if (milliongame != 'y')
return 0;
mill:
cout << "million level!" << endl;
x = (rand()%1000000000);
cout <<"Computers number is between 1 and 1,000,000,000" << endl;
cout << "Your number: "; cin >> PlayerNumber;
if (!cin || PlayerNumber > 1000000000 || PlayerNumber <= 0){
cout << "That's not a number between 1 and 1,000,000,000!" << endl;
PlayerNumber = 0;
system("pause");
system("cls");
goto mill;
}
if (x > PlayerNumber)
cout << "Your number was lower than the computers." << endl;
if (x < PlayerNumber)
cout << "Your number was higher than the computers" << endl;
if (x == PlayerNumber)
{cout << "You Won! \n\nThe computer's number was "<< x << endl; win = true;
}
}
누구나 정말 감사하겠습니다.
아이디어는 플레이어의 숫자가 숫자이고 프로그램이 컴퓨터 번호보다 높거나 낮을 지 여부를 알려주는 것입니다.
는 또한 비주얼 C++ 2012
감사로 컴파일 콘솔 응용 프로그램이므로주의!
이 질문은 [Code Review] (http://codereview.stackexchange.com)에 속해 있기 때문에 주제가 아닌 것처럼 보입니다. – chris