Advertisement
gtw7375

Diagonal principal e secundaria

Oct 16th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. main(){
  2.        
  3.        int i, x;
  4.        int matrix[5][5];
  5.        
  6.      
  7.        
  8.        for(i=0; i<5; i++){
  9.               for(x=0; x<5; x++){
  10.                        printf("Informe um numero:");
  11.                        scanf("%d", &matrix[i][x]);
  12.               }
  13.        }
  14.                
  15.             for(i=0; i<5; i++){
  16.               for(x=0; x<5; x++){
  17.                      
  18.                      if(i==x){
  19.                              printf("PRINCIPAL: %d\n", matrix[i][x]);
  20.                      }
  21.               }
  22.        }    
  23.      
  24.      
  25.        for(i=0; i<5; i++){
  26.                 for(x=0; x<5; x++){
  27.                          if((i+x)==4){
  28.                                       printf("SECUNDARIA: %d\n", matrix[i][x]);
  29.                           }
  30.                 }
  31.        }
  32.      
  33.      
  34.        getch();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement