fork download
  1. #include <stdio.h>
  2.  
  3. /*int factorial(int x){
  4.   int fact =1;
  5.   for( int i=1;i<=x;i++){
  6.   fact= fact*i;
  7.   }
  8.   return fact;
  9.   }
  10. int combination (int n,int r){
  11.   int ncr=factorial(n)/(factorial(r)*factorial(n-r));
  12.   return ncr;
  13.   }*/
  14.  
  15. int main() {
  16.  
  17. int n;
  18. printf("Enter the n: \n");
  19. scanf("%d",&n);
  20.  
  21.  
  22.  
  23. for( int i=0;i<=n;i++){
  24.  
  25. for(int sp=1;sp<=n-i;sp++){
  26. printf(" ");
  27. }
  28. int first =1;
  29. printf("%d",first);
  30.  
  31. for(int j=0;j<=i;j++){
  32. int icj1= first*(i-j)/(j+1);
  33. printf(" %d ",icj1);
  34. }
  35. printf("\n");
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5320KB
stdin
6
stdout
Enter the n: 
                  1  0  
               1  1    0  
            1  2    0    0  
         1  3    1    0    0  
      1  4    1    0    0    0  
   1  5    2    1    0    0    0  
1  6    2    1    0    0    0    0