Nickle Golf・HQ9F+編

  • 整数を真偽値として扱えないのがもどかしい
  • 条件分岐演算子の中でカンマを使うには括弧が必要なのがもどかしい
  • && や || の右オペランドは bool でなければならないので条件分岐の代わりに使いにくい
  • トップレベルで評価した式は出力されるので、単純な Quine は簡単

Hello, world

printf("Hello, world!");

Quine

1

99 bottles of Beer

j=99;for(i=302;--i>1;)printf("%s bottle%s of beer%s%s",j==0?"No more":sprintf("%d",j<0?99:j),j==1?"":"s",i%3>0?" on the wall":j-->0?".\nTake one down and pass it around":".\nGo to the store and buy some more",i%3>1?".\n\n":", ");

FizzBuzz

for(i=0;i++<100;)printf(i%3<1?"Fizz%s\n":"%s\n",i%5<1?"Buzz":i%3<1?"":sprintf("%d",i));

Increment

C と同じように前置と後置の++がある。

x=0
y=x++
# y==0
z=++x
# z==2