puking


私信TA

用户名:puking

访问量:16198

签 名:

等  级
排  名 700
经  验 3797
参赛次数 0
文章发表 20
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

1065
浏览:814
1028
浏览:824
统计字符 (C语言描述运用ctype.h)
浏览:1130

解题思路:

不怎么了解枚举,不知道怎么直接在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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区