プログラムに問題が発生しました。最初の行のみが正しく印刷されます。ここでの回答は.txtファイルです。最初の番号(3)はショップ番号、2番目の番号(5)は製品番号、その他の行は製品の価格です。
3 5
1.27 2.92 3.45 1.09 0.89
1.08 2.25 3.75 1.12 0.69
0.98 2.48 3.62 1.10 0.72
そして、これが私のresults.txtファイルです。魔女はすべて各行の結果です
9.62
8.89
8.90
私のプログラムコード:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
double dienos, results;
int shops;
ifstream fin ("duomenys1.txt");
fin >> shops;
for( int shop = 1; shop <= 3; shop++ ) {
results = 0;
fin >> dienos;
for ( int pricelist = 1; pricelist <= 5; pricelist++ ) {
double price;
fin >> price;
results += price;
}
cout << results << endl;
}
}