Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
一行でじゃんけんをしようかと、そんなことを思ったのでした。
#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

This comment has been minimized.

Copy link
Owner Author

@macrat 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