Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. void main(void)
  5. {
  6.     int tab[7][7];
  7.     short ligne=7,collone = 5, longDiag;
  8.     short i,j,k=0;
  9.  
  10.     /*initialisation tableau*/
  11.     for(i=0; i<ligne; i++)
  12.     {
  13.         for(j=0; j<collone; j++)
  14.         {
  15.             tab[i][j] = k;
  16.             k++;
  17.         }
  18.     }
  19.  
  20.     /*affichage tableau*/
  21.     for(i=0; i<ligne; i++)
  22.     {
  23.         for(j=0; j<collone; j++)
  24.         {
  25.             printf("%d\t",tab[i][j]);
  26.         }
  27.         printf("\n");
  28.     }
  29.  
  30.     /*parcou des diagonal*/
  31.     printf("affichage diagonal\n");
  32.     if(ligne> collone)
  33.         longDiag = collone;
  34.     else
  35.     {
  36.         if(collone >= ligne)
  37.             longDiag = ligne;
  38.     }
  39.  
  40.     for(k=0; k<longDiag; k++)
  41.     {
  42.         for(i=0; i<longDiag; i++)
  43.         {
  44.             j=i+k;
  45.             printf("%d\t",tab[i][j]);
  46.         }
  47.        
  48.         printf("\n");
  49.     }
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement