1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int matrice[10][10] = {{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,3,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,7,0,0,0,0,0,0,0},
{0,0,0,0,0,9,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,8,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0}};
int i =0;
int j=0;
int x = 0;
int y = 0;
int data = 0;
for ( i = 0 ; i<10 ; i++) {
for ( j = 0 ; j<10 ; j++){
printf("%d ",matrice[i][j]);
if (data < matrice[i][j] ){
data = matrice[i][j] ;
x = i;
y = j;
}
}
printf("\r\n");
}
printf("Element max : %d \r\n", data);
printf ("Position X : %d \r\n", x);
printf ("Position y : %d \r\n", y);
} |
Partager