8 is obviously number of lines, then from 2nd line
no1: jersey number of particular player
no2: number of digits remaining
no3,4,5...: if its >0, it indicates how many minutes he played, if its <0, it shows how many mins he was on the bench. He can go out several times (that's why there are several variating digits).
How do I write the code for this?
file>>n;
for(int i=1;i<=n;i++)
what's next?
I assume I can't write "file >> a >> b >> c" in this case ?
You know that there are 8 lines so you need to loop 8 times (you have that code already). Then extract the player's number and then the number signalling the amount of following numbers. Loop for that amount of times. You're basically using the same technique as you did for knowing that you need to loop 8 times:
1 2 3 4 5 6
- Get the amount of lines
- For each line
- Get the player number
- Get the amount of changes
- For each change
- Get the change
Thanks, couldn't believe at first it will be so easy, lol.
What I need to do next is make it check if the first value of time is negative or not (easy enough) and then somehow somewhere store the positive ones |????|(starting lineup) so that later on I could sort them by jersey numbers, how it should be done? I assume it should be something with those A[i] (constructors or how do you call them in English...), but haven't got much clue...
Anyone have an idea how do I store them (together with info to which jersey it belongs) and then call for them so I could sort them by jersey numbers ?
first no - jersey number
2nd - number of following values (times in minutes)
if 3rd value is negative, it means player started game on the bench.
When I try something like this:
1 2 3 4 5 6 7
int n, i, nr[n], laikai, l1, l2;
failas>>n; // number of lines/players
for(int i=1;i<=n;i++){
failas>>nr[i]>>laikai; // nr - number of playing/bench time digits for each player, laikai - actual times.
for (int i=1; i<=laikai;i++){
failas >> l1 >> l2; // seperated time values to check if l1 is negative later on