解题思路:
不怎么了解枚举,不知道怎么直接在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语言代码)答案错误???浏览:595 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:638 |
Wu-求圆的面积 (C++代码)浏览:1892 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:676 |
sizeof的大作用 (C语言代码)浏览:1452 |
1048题解(读入回车问题)浏览:565 |
C二级辅导-求偶数和 (C语言代码)浏览:674 |
字符串比较 (C语言代码)浏览:685 |
C语言训练-大、小写问题 (C语言代码)浏览:682 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:462 |