Skip to content

Instantly share code, notes, and snippets.

@macrat
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macrat/0654a24322f09e946a09 to your computer and use it in GitHub Desktop.
Save macrat/0654a24322f09e946a09 to your computer and use it in GitHub Desktop.
一行でじゃんけんをしようかと、そんなことを思ったのでした。
#include <stdio.h>
int main(int usr, unsigned int cpu, char** hands)
{
return printf((0 <= usr && usr <= 2) ? "you: %s\ncpu: %s\n%s\n" : "incorrect input!\n", hands[usr], hands[cpu%3], ((char*[]){"drow :-)", "lose...", "your! win!!!"})[(3+usr-cpu%3)%3], (usr=-1)&&scanf("%d", &usr), printf("jan! ken!! game!!!\nplease your hand(0:%s 1:%s 2:%s):", hands[0]="guu", hands[1]="choki", hands[2]="paa")) == 17;
}
@macrat
Copy link
Author

macrat commented May 14, 2015

tccでコンパイルしたらちゃんと動かなかった。引数の評価順序が違うらしい。
無理にprintfに入れないで&&で繋いでいけばいいのだけれど、おもしろくない。むずかしい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment