清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int user = -1;
int computer = -1;
int result = -1;
char gesture[3][16] = {"scissor", "stone", "cloth"};
#if
printf("%s\n", gesture[]);
printf("%s\n", gesture[1]);
printf("%c\n", gesture[1][3]);
#endif
#if 1
srand(time(NULL));
while (1) {
// 1. 提示用户进行输入
INPUT:
printf("Please input thegesture (0 - scissor 1 - stone 2 - cloth 3 - quit):\n");
// 2. 接收用户的输入
scanf("%d", &user);
if (user < 0 || user > 3) {
goto INPUT;
}
if (user == 3) {
break;
}
// 3. 程序随机生成石头、剪刀、布中的一种
computer = rand() % 3;
// 4. 打印用户输入和电脑生成的信息
printf("\nYour:%s\tComputer: %s\n", gesture[user], gesture[computer]);
// 5. 根据游戏规则,判断输赢结果
// (U - C + 4 ) % 3 - 1
result = (user - computer + 4) % 3 - 1;
// 6. 输出结果
if (result > 0) {
printf("You Win!\n");
} else if (result == ) {
printf("Draw!\n");
} else {
printf("You lose!\n");
}
}
#endif
printf("Thanks for yourjoin!\n");
return 0;
}