- 分享
- 0
- 人气
- 0
- 主题
- 27
- 帖子
- 1897
- UID
- 80851
- 积分
- 2288
- 阅读权限
- 20
- 注册时间
- 2007-6-6
- 最后登录
- 2014-2-17
- 在线时间
- 3090 小时
|
这是是小弟我的code...
小弟我面对的问题是如何将dice 的号码加起来,然后显示和update 我的界面??
最后是如何重复的roll dice .... 谢谢...
int display()
{
string a[10][10] = {{"100","99","98","97","96","95","94","93","92","91"},
{"81","82","83","84","85","86","87","88","89","90"},
{"80","79","78","77","76","75","74","73","72","71"},
{"61","62","63","64","65","66","67","68","69","70"},
{"60","59","58","57","56","55","54","53","52","51"},
{"41","42","43","44","45","46","47","48","49","50"},
{"40","39","38","37","36","35","34","33","32","31"},
{"21","22","23","24","25","26","27","28","29","30"},
{"20","19","18","17","16","15","14","13","12","11"},
{"1","2","3","4","5","6","7","8","9","10"}};
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
cout << a[i][j] << "\t";
}
cout << endl;
}
}
void display_snake()
{
cout << "======================================" << endl;
cout << " SNAKE POSITION " << endl;
cout << "======================================" << endl;
cout << "\tFROM 18 TO 6" << endl;
cout << "\tFROM 36 TO 14" << endl;
cout << "\tFROM 52 TO 30" << endl;
cout << "\tFROM 65 TO 54" << endl;
cout << "\tFROM 72 TO 24" << endl;
cout << "\tFROM 92 to 48" << endl;
cout << "\tFROM 98 to 57" << endl << endl;
}
void display_ladder()
{
cout << "======================================" << endl;
cout << " LADDER POSITION " << endl;
cout << "======================================" << endl;
cout << "\tFROM 3 TO 25" << endl;
cout << "\tFROM 8 TO 34" << endl;
cout << "\tFROM 37 TO 67" << endl;
cout << "\tFROM 56 TO 78" << endl;
cout << "\tFROM 69 TO 87" << endl;
cout << "\tFROM 71 to 91" << endl;
cout << "\tFROM 80 to 99" << endl << endl;
}
void dice(int random)
{
srand(time(0));
random = (rand()%6 + 1);
cout << "Dice number: " << random << endl ;
}
int main()
{
int random;
int count;
int a[9][9];
string player1, player2;
system("cls");
cout << "=======================================" << endl;
cout << " SNAKE AND LADDER GAME " << endl;
cout << "=======================================" << endl;
cout << endl;
display();
display_snake();
display_ladder();
cout << "Enter Name of Player 1: ";
getline(cin,player1);
cout << endl << "Enter Name of Player 2: ";
getline(cin,player2);
for(int i = 1; i > 0; i++)
{
if(i % 2 == 1)
{
cout << "It's " << player1 << " turn to roll the dice." << endl;
system("pause");
dice(random);
}
else if(i % 2 == 0)
{
cout << "It's " << player2 << " turn to roll the dice." << endl;
system("pause");
dice(random);
}
} |
|