我需要制作一个如下所示的程序:
Player name 1: <input>
Player name 2: <input>
<output> <output>
(Player 1's)Score1: <input1>
Score2: <input2>
(player 2's)Score1: <input1>
Score2: <input2>
(player 1's)<output1>
<output2>
(player 2's)<output1>
<output2>
或准确地说:
Number Player Name Score
Game1 Game2
------ ----------- ------- -------
[1] <name1> <score1> <score2>
[2] <name2> <score1> <score2>
我需要做一个循环来指示名称旁边的数字,但我不知道该怎么做。
这是我的代码:
int main()
{
int x=1;
char player[PLAYERS][LENGTH] = {"-----"};
char scorex[GAME][LENGTH] = {"0.00"};
int i,j;//COUNTERS
for (i=0; i<PLAYERS; i++)
{
printf("Player Name %d:\t",x);
fgets(player[i], LENGTH, stdin);
x++;
}
for (i=0;i<PLAYERS;i++)
{
printf("%10s\n", player[i]);
}
for (x=1; x<=PLAYERS; x++)
{
printf("score %d:\t", x);
for (i=0 ;i<GAME; i++)
{
fgets(scorex[i], LENGTH, stdin);
}
printf("%5s\n", scorex[i]);
}
return 0;
}
我可以用循环做什么?帮助?