How can i read some number from a text file and then go back to read some other information?
All i know, is read it from the beginning to the end, but even when i check something for ex if(fgetc(in)!=...) goes forward one character, and all this messes up my plans :(
Here's the problem i'm trying to solve:
Once, a gardener ordered different kind of flowers which were delivered one after the other. These flowers were
planted line by line by the gardener on the basis of their arriving in an num matrix shape garden.
Write a program that will calculate in which column of the garden will be the most flowers with the same color. If
there will be more solutions you have to write down the first solution (the smallest column index).
The first line contains the number of the test cases. In the corresponding line of each case a string and two positive
integers (separated by spaces) are written. The characters of the string represent the colors of the flowers, the first integer
is the value of n (number of the lines) and the second one is m (number of the columns).
Your program has to print (for each test case) two numbers and one character separated by spaces: the number of
column (the number of start column is 1) in which the most unicolered flowers are, and the number of most flowers with
the same color, and what is this color.
Sample Input: G.IN
ABCBBADCBDBA 4 3
KFPSSKPFFKPSSPFKPSPK 5 4
Sample Output: Standard output
2 3 B
3 4 P
See in the input, i must order the characters in an nxm matrix, but the size is unknow until the end of the line, so i would need to go back and read it :(
I already tought to add it in an array, and then read it back, but there's another problem, the colors can be numbers too, so i don't even know the type before i check the first character...
Any help would be greatly appreciated!
Edited by Incubator: n/a