解题思路:
不怎么了解枚举,不知道怎么直接在scanf中用枚举变量,有大神知道的请赐教
注意事项:
参考代码:
#include <stdio.h>
#include <string.h>
int main()
{
int a,b;
scanf("%d%d",&a,&b);
enum three
{
stone=0, cloth, knife
}bef,aft;
bef=(enum three)a;
aft=(enum three)b;
enum result
{
lose=-1, ping, win
}res;
if(bef-aft==1||bef-aft==-2){
res=(enum result)1;
printf("%d\n",res);
}
if(bef-aft==0){
res=(enum result)0;
printf("%d\n",res);
}
if(bef-aft==-1||bef-aft==2){
res=(enum result)-1;
printf("%d\n",res);
}
return 0;
}
0.0分
2 人评分
模拟计算器 (C++代码)浏览:800 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:530 |
妹子杀手的故事 (C语言代码)浏览:1045 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:713 |
矩阵转置 (C语言代码)浏览:782 |
小O的图案 (C语言代码)浏览:911 |
WU-C语言程序设计教程(第三版)课后习题12.3 (C++代码)浏览:847 |
1250题解浏览:555 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:488 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:462 |