Advertisement
sifat3d

Number Pyramid in C

Jun 16th, 2015
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int doseries(int inp);
  4.  
  5. int main()
  6. {
  7.     int input,i,j,n;
  8.     scanf("%d",&input);
  9.     n=doseries(input);
  10.         printf("\n");
  11.  
  12.  
  13.     for(i=input;i>0;i--)
  14.     {
  15.         for(j=i;j>0;j--)
  16.         {
  17.             if(n<10){printf("0%d ",n--);}
  18.             else printf("%d ",n--);
  19.         }
  20.         printf("\n");
  21.     }
  22.  
  23.     return 0;
  24. }
  25.  
  26.  
  27. doseries(int inp)
  28. {
  29.     int i;
  30.     for(i=inp-1;i>0;i--)
  31.     {
  32.         inp=inp+i;
  33.     }
  34.     return inp;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement