C++ —— 奇偶判断

奇偶判断

需求如下:

 

 

 

 

代码如下:

 

 1 #include <iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     cin>>n;
 7     if(n%2==0) cout<<n<<" is even."<<endl;
 8     else cout<<n<<" is odd."<<endl;
 9     return 0;
10 }

 

写在最后:

  哪里有不足或者错误的地方,欢迎小伙伴们进行指教,一起进步哦!

posted @ 2020-09-09 08:50  闫佳杰  阅读(1681)  评论(0)    收藏  举报