Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 7- Um elemento Aij de uma matriz é dito PONTO DE SELA da matriz A se, e somente se, Aij for ao
- mesmo tempo o MENOR elemento da linha i e o MAIOR elemento da coluna j. Faça um programa
- que receba uma matriz de ordem 50x70. Ao final da entrada, limpar a tela, mostrar a matriz,
- verificar se a matriz possui ponto de sela, e se possuir, mostrar o valor do elemento e sua
- localização (qual linha e coluna).
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include <locale.h>
- #define t 2
- #define u 2
- void zerar(int m[][u])
- {
- int i, j;
- for(i=0; i<t; i++)
- {
- for(j=0; j<u; j++)
- m[i][j] = 0;
- }
- }
- void receber(int m[][u])
- {
- int i, j;
- for(i=0; i<t; i++)
- {
- for(j=0; j<u; j++)
- {
- printf("Digite o valor para M[%d][%d]: ", i+1, j+1);
- scanf("%d", &m[i][j]);
- }
- }
- }
- void mostrar_m(int m[][u])
- {
- int i, j;
- for(i=0; i<t; i++)
- {
- for(j=0; j<u; j++)
- printf("%4d", m[i][j]);
- printf("\n\n");
- }
- }
- int main()
- {
- setlocale(LC_ALL, "portuguese");
- int m1[t][u], sel, aux, cont, l1, l2, c1, c2, i, j, k;
- l1 = l2 = c1 = c2 = cont = 0;
- zerar(m1);
- printf("\n\n");
- receber(m1);
- printf("\n\n");
- printf("\n\n\nA matriz A: \n\n");
- mostrar_m(m1);
- for(i=1; i<t; i++) // >l
- {
- aux = m1[i][0];
- for(j=1; j<u; j++)
- {
- if(aux > m1[i][j])
- {
- aux = m1[i][j];
- l1 = i+1;
- c1 = j+1;
- }
- sel = m1[0][j];
- for(k=1; k<t; k++) //<c
- {
- if(sel < m1[k][j])
- {
- sel = m1[k][j];
- l2 = k+1;
- c2 = j+1;
- }
- }
- if(aux == sel)
- {
- printf("Ponto de sela %d é: %d, localizado em %d,%d", i+1, sel, l1, c1);
- cont++;
- }
- }
- }
- if(cont == 0)
- printf("Não há ponto de sela!!!");
- printf("\n\n\n\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement