LOVEGUN

APP Majid

Dec 7th, 2021 (edited)
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int t[8][8],i,j,test1,test2,test3,test4,r,a,b;
  7.     for (i=0;i<8;i++)
  8.     {
  9.         for (j=0;j<8;j++)
  10.         {
  11.             t[i][j]=0;
  12.         }
  13.     }
  14.     do{
  15.         printf ("Saisir A et B: ");
  16.         scanf ("%d%d",&a,&b);
  17.     }while ((a<0 || a>8) || (b<0 || b>8));
  18.     printf ("Matrice Avant transformation:\n ");
  19.     for (i=0;i<8;i++)
  20.     {
  21.         for (j=0;j<8;j++)
  22.         {
  23.             printf ("%d|",t[i][j]);
  24.         }
  25.         printf ("\n");
  26.     }
  27.     r=-1;
  28.     do
  29.     {
  30.         r++;
  31.         test1=0 ; test2=0 ; test3=0 ; test4=0;
  32.         if (a-r>=0 && b-r>=0)
  33.         {
  34.             t[a-r][b-r]=1;
  35.             test1=1;
  36.  
  37.         }if (a-r>=0 && b+r<8)
  38.         {
  39.             t[a-r][b+r]=1;
  40.             test2=1;
  41.  
  42.  
  43.         }if (a+r<8 && b-r>=0)
  44.         {
  45.             t[a+r][b-r]=1;
  46.             test3=1;
  47.  
  48.  
  49.         }if (a+r<8 && b+r<8)
  50.         {
  51.             t[a+r][b+r]=1;
  52.             test4=1;
  53.         }
  54.     }while (test1==1 || test2==1 || test3==1 || test4==1);
  55.      printf ("Matrice après transformation:\n");
  56.     for (i=0;i<8;i++)
  57.     {
  58.         for (j=0;j<8;j++)
  59.         {
  60.             printf ("%d|",t[i][j]);
  61.         }
  62.         printf ("\n");
  63.     }
  64. }
  65.  
Add Comment
Please, Sign In to add comment