Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int t[8][8],i,j,test1,test2,test3,test4,r,a,b;
- for (i=0;i<8;i++)
- {
- for (j=0;j<8;j++)
- {
- t[i][j]=0;
- }
- }
- do{
- printf ("Saisir A et B: ");
- scanf ("%d%d",&a,&b);
- }while ((a<0 || a>8) || (b<0 || b>8));
- printf ("Matrice Avant transformation:\n ");
- for (i=0;i<8;i++)
- {
- for (j=0;j<8;j++)
- {
- printf ("%d|",t[i][j]);
- }
- printf ("\n");
- }
- r=-1;
- do
- {
- r++;
- test1=0 ; test2=0 ; test3=0 ; test4=0;
- if (a-r>=0 && b-r>=0)
- {
- t[a-r][b-r]=1;
- test1=1;
- }if (a-r>=0 && b+r<8)
- {
- t[a-r][b+r]=1;
- test2=1;
- }if (a+r<8 && b-r>=0)
- {
- t[a+r][b-r]=1;
- test3=1;
- }if (a+r<8 && b+r<8)
- {
- t[a+r][b+r]=1;
- test4=1;
- }
- }while (test1==1 || test2==1 || test3==1 || test4==1);
- printf ("Matrice après transformation:\n");
- for (i=0;i<8;i++)
- {
- for (j=0;j<8;j++)
- {
- printf ("%d|",t[i][j]);
- }
- printf ("\n");
- }
- }
Add Comment
Please, Sign In to add comment