Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. //6. Faça um programa que contenha uma função que receba uma matriz como entrada e que determine o maior
  2. //   elemento da matriz. No programa principal (main), exiba a matriz e o seu maior elemento usando a função
  3. //   construída.
  4.  
  5. #include<stdio.h>
  6.  
  7. int tyrion (int z,int *mat)
  8. {
  9.     int i,j;
  10.     int maior=0;
  11.     for(i=0;i<z;i++){
  12.         for(j=0;j<z;j++){
  13.             if(maior<mat[i][j]){
  14.                 maior=mat[i][j];
  15.             }
  16.         }
  17.     }
  18.     return maior;
  19. }
  20. main()
  21. {
  22.     int x;
  23.     printf("Insira a ordem da sua matriz: ");
  24.     scanf("%d",&x);
  25.     int l,c,pennywise[x][x];
  26.     for(l=0;l<x;l++){
  27.         for(c=0;c<x;c++){
  28.             printf("Insira o elemento da %d coluna e %d linha: ",l+1,c+1);
  29.             scanf("%d",&pennywise[l][c]);
  30.         }
  31.     }
  32.     printf("A matriz inserida e:");
  33.     for(l=0;l<x;l++){
  34.         printf("\n");
  35.         for(c=0;c<x;c++){
  36.             printf("\t%d",pennywise[l][c]);
  37.         }
  38.     }
  39.     printf("\n");
  40.     printf("O maior numero da matriz e %d.",tyrion(x,pennywise));
  41.     printf("\n");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement