Advertisement
Guest User

talha

a guest
Nov 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5.     int n,i,j,x,k;
  6.     while(1)
  7.     {
  8.         scanf("%d",&n);
  9.         if(n==0)
  10.             break;
  11.         else
  12.         {
  13.            for(i=0;i<n;i++)
  14.     {
  15.         for(j=0,k=i;j<n;j++,k++)
  16.         {
  17.             x=pow(2,k);
  18.             if(n==1||n==2)
  19.             printf("%2d",x);
  20.             else if(n==3)
  21.                 printf("%3d",x);
  22.             else if(n==4)
  23.                 printf("%4d",x);
  24.             else if(n==5)
  25.                 printf("%5d",x);
  26.             else if(n==6)
  27.                 printf("%6d",x);
  28.             else if(n==7)
  29.                 printf("%7d",x);
  30.             else if(n==8)
  31.                 printf("%8d",x);
  32.             else if(n==9)
  33.                 printf("%9d",x);
  34.             else if(n==10)
  35.                 printf("%10d",x);
  36.             else if(n==11)
  37.                 printf("%11d",x);
  38.             else if(n==12)
  39.                 printf("%12d",x);
  40.             else if(n==13)
  41.                 printf("%13d",x);
  42.             else if(n==14)
  43.                 printf("%14d",x);
  44.             else if(n==15)
  45.                 printf("%15d",x);
  46.         }
  47.      printf("\n");
  48.     }
  49.         }
  50.     }
  51.  
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement