Help scanning in numbers and printing format
I have an assignment where I have to read in numbers from a file using redirect and then break them up into groups, find the highest number, and print them in a certain way.
I'm currently trying to figure this part out and will probably have questions about finding and printing the highest number.
The file the numbers are stored in a file and is formatted like
Code:
3 9 8 7 6 5 4 3 2 1
So far this is what I have to print out the Group number and the numbers. However this will only print on the first line with "Group1".
Code:
for(i = 1; i <= group; i++) {
printf("Group %d: ", i);
while(count < 3) {
scanf("%d", &num);
printf("%d ", num);
count++;
} //while
Output should look something like this(it should all be right aligned):
Code:
Number1 Number2 Number3
Group1 9 8 7
Number1 Number2 Number3
Group2 6 5 4
Number1 Number2 Number3
Group3 3 2 1