我正在学习如何编写一个游戏,我已经给了游戏的以下规则。用户想玩多少次c语言
- 规则1:玩家必须定义一个最小数目以停止此必须转弯大于10
- 规则2:从圆形所有点被添加到总
- 规则3:如果骰子第一名得分为1,那一轮的所有得分都被没收
- 规则4:第一名获得101分的玩家获胜!
我想在用户输入有多少玩家后输入游戏的数量。
我的问题是,它要求用户每次我取决于我有多少玩家输入
例
多少玩家进入球员的名字:3
多少游戏:15
输入玩家姓名:约翰
多少游戏:15(我再次输入这个号码)我不需要这条线在这里
输入球员姓名:玛丽
多少游戏:15(我再次输入这个号码)我不需要在这里这条线
输入球员姓名:巴里
多少游戏:15(我再次输入这个号码),我不需要在这里这条线
这是我的问题代码:
//user inputs value of player_num, here, as you have now//
printf_s("Please type in the number of players: ");
scanf_s("%d", &player_num, sizeof(int));
for (i = 0; i < player_num; i++) {
//user inputs value of num_game, here, as you have now//
printf_s("Please type in the number of games: ");
scanf_s("%d", &num_games, sizeof(int));
num_games = (j = 1, num_games);
printf_s("Enter the player's first name: ");
scanf_s("%s", names[i], 25);
getchar();
}
printf_s("\n");
for (i = 0; i < player_num; i++)
printf_s("\n%s", names[i]);
构建您的代码,以便它符合您的要求。 – ThingyWotsit
您可以改进您的[mcve],但它是全球性的一个很好的问题。 – Stargateur
https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – TessellatingHeckler