C言語版最も簡単なゲーム-ハサミ石布
C言語版最も簡単なゲーム-ハサミ石布
ctrl+cが終了します.
ctrl+cを使用してプログラムを終了します.
#include
#include
#include
/*************\
* *
* *
\*************/
int main(void){
char gesture[3][10] = {"scissor","stone","cloth"};
int man, computer, result, ret;
/* */
srand(time(NULL));
while(1){
computer = rand()%3;
printf("
Input your gesture 0-scissor 1-stone 2-cloth:
");
ret = scanf("%d", &man);
if(ret !=1 || man<0 || man>2){
printf("Invalid input!
");
return 1;
}
printf("Your gesture:%s\tComputer's gesture: %s
",
gesture[man], gesture[computer]
);
result = (man - computer + 4) %3 -1;
if(result > 0)
printf("YOU WIN!
");
else if(result == 0)
printf("Draw!
");
else
printf("You lose!
");
}
return 0;
}
ctrl+cが終了します.
ctrl+cを使用してプログラムを終了します.