I have problem with my program,I need to write to file how much games each player played in 5 days ,here is my txt file:first number in first line is how much days they played,first number from line 2 to line 5 is how much days they played,other numbers in each line is how much games they played in these days:
5
5 3 2 3 1 2
3 6 2 4
4 2 2 1 2
3 3 3 3
2 3 4
Here is my program:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int programuotojai,programos;
ifstream fin ("duomenys.txt");
fin >> programuotojai; //players
for(int i = 1; i <= 6; i++){
fin >> programos; //games played
cout << programos;
}
}
Can you help me to write this program to the end,thanks.
After reading the number of games played, you need to read the games themselves. Something like:
Also use
programuotojaiinstead of the constant 6(if I get the code correctly).I will not write the complete program but it seems to me you have to sum the numbers on each line.