#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
using namespace std;
//函数的声明
void pick_a_card(int&,int&);
void spin_the_wheel(int&);
void choose_card_or_wheel(int,int&,int&);
void check_the_location(int,int&,int&);
void roll_the_dice(int&);
ofstream outfile("C:\\BDGAME.OUT");
int main()
{
    int player1_spot=0,player2_spot=0;
    int player,card_number;
    srand(time(0));
    do
    {
        outfile<<"\nPlayer 1-Enter 1 toroll the dice."<<endl;
        cout<<"\nPlayer 1-Enter 1 toroll the dice."<<endl;
        cin>>player;
        roll_the_dice(player1_spot);
        check_the_location(plyer,player1_spot,card_numb);
        if(player1_spot>=90)
            break;
        outfile<<"\nPlayer 2-Enter 2 toroll the dice."<<endl;
        cout<<"\nPlayer 2-Enter 2 toroll the dice."<<endl;
        cin>>player;
        roll_the_dice(player2_spot);
        check_the_location(plyer,player2_spot,card_numb);
    }
    while(player2_spot<90);
}
void roll_the_dice(int& spot)
{
    int roll;
    roll=rand()%11+2;
    spot+=roll;
    outfile<<"you rolled"<<roll<<endl;
    cout<<"you rolled"<<roll<<endl;
}
void check_the_location(int player,int& spot,int& card_numb)
{
    int choose;
    outfile<<"you landed on spot"<<spot<<endl;
    cout<<"you landed on spot"<<spot<<endl;
    if(spot==30)
    {
        outfile<<"you get the shortcut to 70."<<endl;
        cout<<"you get the shortcut to 70."<<endl;
        spot=70;
    }
    if(spot==10||spot==60)
    {
        pick_a_card(spot,card_numb);
    }
    else if(spot==40||spot==70)
    {
        spin_the_wheel(spot);
    }
    else if(spot==80)
    {
        choose_card_or_wheel(spot,card_number);
    }
    else if(spot>=90)
    {
        outfile<<"Player"<<player<<"wins!"<<endl;
        cout<<"Player"<<player<<"wins!"<<endl;
    }
    else
    {
        outfile<<"Keep playing!"<<endl;
        cout<<"Keep playing!"<<endl;
    }
    return;
}
void choose_card_or_wheel(int& spot,int& card_number)
{
    int choice;
    outfile<<"enter 1 to spin the wheel or 2 to pick a card."<<endl;
    cout<<"enter 1 to spin the wheel or 2 to pick a card."<<endl;
    if(choice==1)
    {
        spin_the_wheel(spot);
    }
    else
    {
        pick_a_card(spot,card_number);
    }
    return;
}
void spin_the_wheel(int& spot)
{
    int spin;
    outfile<<"you get to spin the wheel!"<<endl;
    cout<<"you get to spin the wheel!"<<endl;
    spin=rand()%8+1;
    if(spin==1)
    {
        spot-=4;
        outfile<<"go back 4.you are at spot"<<spot<<endl;
        cout<<"go back 4.you are at spot"<<spot<<endl;
    }
    else if(spin==2)
    {
        spot+=2;
        outfile<<"go forward 2.you are at spot"<<spot<<endl;
        cout<<"go forward 2.you are at spot"<<spot<<endl;
    }
    else if(spin==3)
    {
        spot-=6;
        outfile<<"go back 6.you are at spot"<<spot<<endl;
        cout<<"go back 6.you are at spot"<<spot<<endl;
    }
    else if(spin==4)
    {
        spot-=9;
        outfile<<"go back 9.you are at spot"<<spot<<endl;
        cout<<"go back 9.you are at spot"<<spot<<endl;
    }
    else if(spin==5)
    {
        spot=0;
        outfile<<"go back to the beginning.you are at spot"<<spot<<endl;
        cout<<"go back to the beginning.you are at spot"<<spot<<endl;
    }
    else if(spin==6)
    {
        spot-=8;
        outfile<<"go back 8.you are at spot"<<spot<<endl;
        cout<<"go back 8.you are at spot"<<spot<<endl;
    }
    else if(spin==7)
    {
        spot-=7;
        outfile<<"go back 7.you are at spot"<<spot<<endl;
        cout<<"go back 7.you are at spot"<<spot<<endl;
    }
    else
    {
        spot+=1;
        outfile<<"go forward 1.you are at spot."<<spot<<endl;
        cout<<"go forward 1.you are at spot."<<spot<<endl;
    }
    return;
}
void pick_a_card(int& spot,int& card_number)
{
    outfile<<"you get to pick a card!"<<endl;
    cout<<"you get to pick a card!"<<endl;
    card_numb++;
    if(card_num==11)
        card_num=1;
    if(card_num==1)
    {
        spot-=9;
        outfile<<"go back 9.you are at spot"<<spot<<endl;
        cout<<"go back 9.you are at spot"<<spot<<endl;
    }
    else if(card_num==2)
    {
        spot=0;
        outfile<<"go back to the beginning.you are at spot"<<spot<<endl;
        cout<<"go back to the beginning.you are at spot"<<spot<<endl;
    }
    else if(card_num==3)
    {
        spot-=3;
        outfile<<"go back 3.you are at spot"<<spot<<endl;
        cout<<"go back 3.you are at spot"<<spot<<endl;
    }
    else if(card_num==4)
    {
        spot-=8;
        outfile<<"go back 8.you are at spot"<<spot<<endl;
        cout<<"go back 8.you are at spot"<<spot<<endl;
    }
    else if(card_num==5)
    {
        spot+=2;
        outfile<<"go forward 2.you are at spot."<<spot<<endl;
        cout<<"go forward 2.you are at spot."<<spot<<endl;
    }
    else if(card_num==6)
    {
        spot-=8;
        outfile<<"go back 8.you are at spot."<<spot<<endl;
        cout<<"go back 8.you are at spot."<<spot<<endl;
    }
    else if(card_num==7)
    {
        spot+=1;
        outfile<<"go forward 1.you are at spot."<<spot<<endl;
        cout<<"go forward 1.you are at spot."<<spot<<endl;
    }
    else if(card_num==8)
    {
        spot+=1;
        outfile<<"go forward 3.you are at spot."<<spot<<endl;
        cout<<"go forward 3.you are at spot."<<spot<<endl;
    }
    else if(card_num==9)
    {
        spot=0;
        outfile<<"go back to the beginning.you are at spot"<<spot<<endl;
        cout<<"go back to the beginning.you are at spot"<<spot<<endl;
    }
    else if(card_num==10)
    {
        spot-=4;
        outfile<<"go back 4.you are at spot."<<spot<<endl;
        cout<<"go back 4.you are at spot."<<spot<<endl;
    }
    else
    {
        spot+=6;
        outfile<<"go forward 6.you are at spot."<<spot<<endl;
        cout<<"go forward 6.you are at spot."<<spot<<endl;
    }
    return;
}
Compiling...
1-1.cpp
C:\Documents and Settings\Administrator\桌面\1-1.cpp(27) : error C2065: 'plyer' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1-1.cpp(27) : error C2065: 'card_numb' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1-1.cpp(38) : warning C4508: 'main' : function should return a value; 'void' return type assumed
C:\Documents and Settings\Administrator\桌面\1-1.cpp(70) : error C2660: 'choose_card_or_wheel' : function does not take 2 parameters
C:\Documents and Settings\Administrator\桌面\1-1.cpp(166) : error C2065: 'card_num' : undeclared identifier
执行 cl.exe 时出错.
1-1.obj - 1 error(s), 0 warning(s)
我老是看不懂错误的提示,改不了啊.

											
	    