C++ C++;完成随机猜我的数字游戏查找

C++ C++;完成随机猜我的数字游戏查找,c++,visual-studio-2012,console,verify,C++,Visual Studio 2012,Console,Verify,我想知道是否有人可以在我的代码中查找这个“随机猜我的数字游戏” 以下是所有代码: #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(){ sran

我想知道是否有人可以在我的代码中查找这个“随机猜我的数字游戏”

以下是所有代码:

#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;
}


}
#包括
#包括
#包括
#包括
使用名称空间std;
int PlayerNumber,x;
布尔温=假;
龙富,;
千分之一字符;
int main(){
srand(时间(空));
cout这段代码:

if (milliongame ==  'y')
{goto mill;}
else
return 0;

mill:

    cout << "million level!" << endl;
为此:

switch ( foo )
{
    case 20:
        foo = 25;
        break;
    case 200:
        foo = 250;
        break;
    case 2000:
        foo = 2500;
        break;
}
这是:

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;}

这段代码应该在哪里。

这个问题似乎离题了,因为它属于on。@user2635139,没错,我已经解决了这个问题。
switch ( foo )
{
    case 20:
        foo = 25;
        break;
    case 200:
        foo = 250;
        break;
    case 2000:
        foo = 2500;
        break;
}
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;}
if (x > PlayerNumber)
    cout << "Your number was lower than the computers." << endl;
else if (x < PlayerNumber)
    cout << "Your number was higher than the computers" << endl;
else
{
    cout << "You Won! \n\nThe computer's number was "<< x << endl; 
    win=true;
}
void result(int PlayerNumber, int x)
{
    if (x > PlayerNumber)
            cout << "Your number was lower than the computers." << endl;
    else if (x < PlayerNumber)
            cout << "Your number was higher than the computers" << endl;
    else
    {
        cout << "You Won! \n\nThe computer's number was "<< x << endl; 
        win=true;
    }
}
result(PlayerNumber,x);