Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*2. Faça um algoritmo que leia uma matriz de dimensão 3 x 3 e apresente na tela o maior e o menor elemento
- da matriz.*/
- #include <stdio.h>
- #include <stdlib.h>
- #define tam 3
- main()
- {
- int i,j,mata[tam][tam],maior,menor;
- for (i = 0; i < tam; i++)
- {
- for (j = 0; j < tam; j++)
- {
- printf("Informe o numero: ");
- scanf("%i", &mata[i][j]);
- if ( i == 0 && j == 0)
- {
- maior = mata [i][j];
- menor = mata [i][j];
- }
- else if (mata[i][j] > maior)
- {
- maior = mata[i][j];
- }
- if (mata[i][j] < menor)
- {
- menor = mata[i][j];
- }
- }
- }
- printf("Maior = %i || Menor = %i\n",maior,menor);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement