解题思路:
不怎么了解枚举,不知道怎么直接在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语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:823 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:804 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:733 |
C语言训练-数字母 (C语言代码)浏览:582 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:532 |
WU-陶陶摘苹果2 (C++代码)浏览:967 |
WU-判定字符位置 (C++代码)浏览:1395 |
WU-链表数据求和操作 (C++代码)浏览:1312 |
水仙花 (C语言代码)浏览:1045 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:466 |