fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  5. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13. int n = 5;
  14. for(int i = n; i >= 1; i--){
  15. for(int j = 1; j <= n; j++){
  16. if(j == 1 || i == j || i == 1){
  17. printf("%d ", j);
  18. }
  19. else{printf(" ");}
  20. }
  21. for(int j = n - 1; j >= 1; j--){
  22. if(j == 1 || i == j || i == 1){
  23. printf("%d ", j);
  24. }
  25. else{printf(" ");}
  26. }
  27. printf("\n");
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
1       5       1 
1     4   4     1 
1   3       3   1 
1 2           2 1 
1 2 3 4 5 4 3 2 1