現在、私はクラスのプログラムを書いており、ファイルの入出力を使用する必要があります。彼女は、7 つの数字 (すべて整数) の 8 つの異なるセットであるファイルをくれました。ユーザーが読みたい行を入力してから、最大数、最小数、一連の数の合計、および一連の平均を出力する必要があります。XCode が 1 行の数字だけを読み取るのに問題があります。getline()
それが解決策でさえあるとしても、私はこの機能をあまり練習していません。
助言がありますか?
これが宿題であることを考えると、特定の主題を知っていることを示すために効率が犠牲になりますが、コードは漠然としたアイデアを提供するはずです。
注**これは、ユーザーが1行しか入力できず、プログラムが終了する場合にのみ機能します
cout << "enter line...";
cin >> line;
//error check line to make sure it is in bounds
///loops through each set of 7 numbers LINE times
//loop through line(FOR LOOP)
//read in the 7 vars
//end loop
//loop through array(FOR LOOP)
//add array[i] onto sum
//is this number higher than the var HIGH? if yes then set high equal to array element
//is this number lower than the low var? if yes then set low equal to array element
//end loop