Advertisement
pimentinha3001

Matriz com IF

Jun 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<stdio.h>
  2. main(){
  3.     int mat[3][3];
  4.     int l,c,n;
  5.    
  6.     for(l=0;l<3;l++){
  7.         printf("\n Digite numero inteiro entre 1 e 15:");
  8.         for(c=0;c<3;c++){
  9.             inicio:
  10.                 scanf("%d",&n);
  11.                 if((n<1) || (n>15)){
  12.                     printf("\n Erro! Numero Invalido, digite novamente:");
  13.                     goto inicio;
  14.                 }
  15.         }}
  16.         printf("\n |Matriz 3x3|\n");
  17.     for(l=0;l<3;l++){
  18.         for(c=0;c<3;c++){
  19.         printf("\t%d",mat[l][c]);
  20.         }
  21.         printf("\n");
  22.         }
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement