SHARE
TWEET

h

a guest Oct 18th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX 99
  4. #define MIN 10
  5. #define TAMANHO 5
  6.  
  7. void PreencherExibir(int Matriz[TAMANHO][TAMANHO]);
  8.  
  9. int main()
  10. {
  11.     int opcao;
  12.     int Matriz[TAMANHO][TAMANHO];
  13.     do{
  14.         printf("Opcoes:\n");
  15.         printf("1 Preencher e exibir: \n");
  16.         printf("0 Sair: \n");
  17.         scanf("%i", &opcao);
  18.         if(opcao == 0)
  19.             printf("\nFIM\n");
  20.         else if(opcao == 1)
  21.             PreencherExibir(Matriz);
  22.     }while(opcao != 0);
  23.  
  24.     return 0;
  25. }
  26.  
  27. void PreencherExibir(int Matriz[TAMANHO][TAMANHO])
  28. {
  29.     int i, j;
  30.     for(i = 0; i < TAMANHO; i++){
  31.         for(j = 0; j < TAMANHO; j++){
  32.             if(i <= j)
  33.                 Matriz[i][j] = rand() % (MAX - MIN + 1) + MIN;
  34.             else
  35.                 Matriz[i][j] = 0;
  36.         }
  37.     }
  38.     for(i = 0; i < TAMANHO; i++){
  39.         for(j = 0; j < TAMANHO; j++){
  40.             printf("\t%i", Matriz[i][j]);
  41.         }
  42.         printf("\n");
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top