Hey guys.
I'm learning by myself the C Development... But I've got a serious problem with one my application.
The exercice is:
Create a board of 10 lines and 3 columns.
Scanf this board.
Check the 3 highest numbers of each line, add them
And just printf the highest sum of the three.
I've tried during two weeks... But nothing happen...
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <windows.h>
main ()
{
int Tab[5][3]={0}, i, j, GrandA = 0, GrandB = 0, GrandC = 0;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 5; j++)
{
scanf("%d", &Tab[j][i]);
}
}
for(i = 0; i < 3; i++)
{
for(j = 0; j < 5; j++)
{
printf("%d\t", Tab[j][i]);
}
printf("\n");
}
for(i = 0; i < 3; i++)
{
printf("\n");
GrandA = 0;
GrandB = 0;
GrandC = 0;
for(j = 0; j < 5; j++)
{
if(GrandA < Tab[j][i])
{
GrandA = Tab[j][i];
Tab[j][i] = 0;
j = 0;
i = 0;
}
if(GrandB < Tab[j][i])
{
GrandB = Tab[j][i];
Tab[j][i] = 0;
j = 0;
i = 0;
}
if(GrandC < Tab[j][i])
{
GrandC = Tab[j][i];
Tab[j][i] = 0;
}
}
printf("%d ", GrandA);
printf("%d ", GrandB);
printf("%d ", GrandC);
}
}
That's what I've done...
Be gentle I'm new and English isn't my mother language.
Thanks for helping me.