【发布时间】:2010-12-06 03:58:02
【问题描述】:
我需要一点编程帮助来上课。我写了下面的代码,但是我的老师说我在读取数据文件时需要使用 2 个 for 循环。我不知道该怎么做...有什么建议吗?
我的代码:
ifstream infile;
infile.open("dive.txt");
for(int i = 0; i <= 6; i++)
infile >> contestantNames[i][0] >> contestantNames[i][1] >> judgeScores[i][0] >> judgeScores[i][1] >> judgeScores[i][2] >> judgeScores[i][3] >> judgeScores[i][4] >> judgeScores[i][5] >> judgeScores[i][6] >> judgeScores[i][7];
infile.close();
【问题讨论】:
-
您的老师可能希望您使用两个嵌套循环,而不是手动从 0 变为 7。
-
能否请您为 100 位参赛者发布您的示例? (与
contestantNames[100][100])