1708 - 初级第五课——判断奇偶数
判断一个整数的奇偶性,如果是奇数,请输出“ji”,如果是偶数,请输出“ou”
Input
输入一行,只有一个整数x (-10000<=x <=10000)
Output
输出只有一行字符(这意味着末尾有一个回车符号)
Examples
Input
5
Output
ji
Solution C
#include <stdio.h> #include <stdlib.h> int main() { int b; scanf("%d",&b); if(b%2==0) printf("ou\n"); else printf("ji\n"); }
Solution C++
#include<iostream> using namespace std; int main() { int a,b,c,d; cin>>a; b=a/2; d=a+1; c=d/2; if(c>b) cout<<"ji"<<endl; if(c<=b) cout<<"ou"<<endl; }