竞赛
考级
(悲
题解
#include<bits/stdc++.h> using namespace std; int main(){ int n;//定义 cin>>n; if(n%2==1){//是否是闰年 cout<<"odd"; } else{ cout<<"even"; } return 0;//好习惯 }
A308.奇偶判断
优先取个位 位运算 三目运算符
1,先设置一个变量num。2,输入变量值。3,判断:如果num%2的值是1那么输出"odd" 否则输出"even"。 参考代码如下:
代码如下: #include<bits/stdc++.h> using namespace std; int main(){ int a; cin>>a; if(a%2==0){ cout<<"even"; } else{ cout<<"odd"; } return 0; }
n=int(input()) if n %2==1: print('odd') else: print('even')
共29条
提交答案之后,这里将显示提交结果~