我需要一些編程幫助。我寫了下面的代碼,但是我的老師說在讀數據文件時我需要使用2 for循環。我不知道該怎麼做......有什麼建議嗎?將1個C++循環轉換爲2個
我的代碼:
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。 – thkala 2010-12-06 04:02:06
你可以請你提供100個參賽者的例子嗎? (with`contestantNames [100] [100]`) – ruslik 2010-12-06 04:02:42