Advertisement
Lisaveta777

to make better triangles

Dec 20th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define N 5
  4.  
  5. //https://otvet.mail.ru/question/217761600
  6.  
  7.  
  8. int main()
  9. {
  10.     int i,j;
  11.  
  12.     for(i=0;i<N;i++)//one
  13.     {
  14.         for(j=0;j<N;j++)
  15.         {
  16.             if(i+2>N-j)
  17.                 printf("%d",N-j);
  18.             else
  19.                 printf(" ");
  20.          }
  21.         printf("\n");
  22.     }
  23.      for(i=0;i<N;i++)//two
  24.     {
  25.         for(j=0;j<N;j++)
  26.         {
  27.             if(j>i)
  28.                 printf("%d",N-j);
  29.             else
  30.                 printf(" ");
  31.          }
  32.         printf("\n");
  33.     }
  34. ///////////////
  35. for(i=0;i<N;i++)//three
  36.     {
  37.         for(j=0;j<2*N;j++)
  38.         {
  39.             if(i>j||j>=N)
  40.                 printf(" ");
  41.             else
  42.                 printf("%d",j+1);
  43.          }
  44.         printf("\n");
  45.     }
  46.      for(i=0;i<N-1;i++)//four
  47.     {
  48.         for(j=0;j<2*N;j++)
  49.         {
  50.             if(j>i+N||j<N-1)
  51.                 printf(" ");
  52.             else
  53.                 printf("%d",2*N-j-1);
  54.          }
  55.         printf("\n");
  56.     }
  57.  
  58.  
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement