Hi
i want to find the max vaule in each row of my 2d array so if i have something like this :
45 |
45 |
32 |
2345 |
45 |
25 |
454 |
45 |
32 |
437 |
45 |
45 |
454 |
45 |
45 |
45 |
i would like the output to be the following :
day 1: 2345
day 2: 454
day 3 : 437
day 4 : 454
With my code bellow i am getting...
day 1: 2345
day 2 : 2345
day 3 : 2345
day 4 : 2345
So it finds the maximum and if the other maximums from other rows are smaller it prints the maximum from the row before.. if that makes sense:
Code:
int LargestDay() {
int d,w,q=0;
int largeD[i];
printf("The largest number of phones sold on a given day:\n");
for(d=0;d<i;d++)
{
for(w=0;w<=j;w++)
{
if( array[d][w]>q)
q=array[d][w];
}
printf("\t Day %d is %d\n",d+1,q);
}
printf ("\n");
}
i and j are global
thanks for your help