乐迪ZYK


私信TA

用户名:RM666

访问量:496

签 名:

欧阳娜娜

等  级
排  名 13405
经  验 870
参赛次数 3
文章发表 4
年  龄 0
在职情况 学生
学  校 淮南乐迪编程教育(苏果校区)
专  业

  自我简介:

解题思路:用不用枚举类型均可!
注意事项 :不要大意!
参考代码:

#include<iostream>

using namespace std;

int main()

{

enum caiquan

{

shitou,  // 0

bu,  // 1

jiandao    // 2

};

int a,b;

cin>>a>>b;

if((a==shitou&&b==jiandao)||(a==jiandao&&b==bu)||(a==bu&&b==shitou)) cout<<"1"<<endl;

else if(a==b) cout<<"0"<<endl;

else cout<<"-1"<<endl;

return 0;

}

//高级枚举


#include<iostream>

using namespace std;

int main() {

   int a, b;

   while(cin>>a>>b) 

{

       if(a-b==-1||a-b==2)

 {

           cout<<-1<<endl;

       } else if(a-b==1||a-b==-2)

 {

           cout<<1<<endl;

       } else if(a-b==0)

 {

           cout<<0<<endl;

       }

   }

   return 0;

}

//普通循环

 

0.0分

2 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区