fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int i,n,j,k=1;
  6. scanf("%d",&n);
  7. printf("Enter the no. of elements");
  8. for(i=1;i<=2*n;i++)
  9. {
  10. if(i<=n)
  11. {
  12. for(j=1;j<=i;j++)
  13. printf("%d",j);
  14. }
  15. else
  16. {
  17. for(j=1;j<=i-(2*k);j++)
  18. printf("%d",j);
  19. k++;
  20. }
  21. printf("\n");
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 9432KB
stdin
9
stdout
Enter the no. of elements1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678
1234567
123456
12345
1234
123
12
1