Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 138 characters in body
Source Link

C, 135(削除) 135 (削除ここまで) 128 characters

-7 characters thanks to kevin cruijssen

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;;++i<22;i<10?h--:h++,p("\n"){)for(j=0;++j<11;){for(p(j==10?"0":"%d",j);for(,k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

C, 135 characters

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

C, (削除) 135 (削除ここまで) 128 characters

-7 characters thanks to kevin cruijssen

#define p printf
i=1,j,h=9,k;main(){for(;++i<22;i<10?h--:h++,p("\n"))for(j=0;++j<11;)for(p(j==10?"0":"%d",j),k=1;k++<h;)p(" ");}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

added prettify markup
Source Link
mbomb007
  • 23.6k
  • 7
  • 66
  • 143

C -, 135 characters

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}
#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}
i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

C - 135 characters

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

C, 135 characters

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

Source Link

C - 135 characters

#define p printf
i=1,j,h=9,k;main(){for(i;++i<22;){for(j=0;++j<11;){p(j==10?"0":"%d",j);for(k=1;k++<h;){p(" ");}}i<10?h--:h++;p("\n");}}

Try it online!


Fun bonus:

On my first compile I got the logic backwards and ended up with the output in reverse

i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}

Edit: removed missed whitespace

AltStyle によって変換されたページ (->オリジナル) /