C语言题目集-分西瓜
生活随笔
收集整理的這篇文章主要介紹了
C语言题目集-分西瓜
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Statement
Neptune 和 Nepgear 買了一個西瓜,重量為 n。
Neptune 和 Nepgear 打算吃掉這個西瓜。在此之前,Neptune 和 Nepgear 希望把西瓜切成兩塊。
現在,Neptune 和 Nepgear 想要知道,是否存在一種切法,使得得到的兩塊西瓜重量都是偶數。
Neptune 和 Nepgear 當然會這個問題,但 Neptune 和 Nepgear 想考考你,所以 Neptune 和
Nepgear 希望你能解決這個問題。
Input
第一行包含一個整數 n (1 <= n <= 100),代表 Neptune 和 Nepgear 的西瓜的重量。
Output
如果期望的切法存在,輸出YES;否則輸出NO。
Example
Input
8
Output
YES
Note
在樣例中,Neptune 和 Nepgear 可以把西瓜切成重量分別為 4 和 4 的兩塊,或者把西瓜切成重量分別為 2 和 6 的兩塊。
#include<stdio.h> int main() {int x;scanf("%d",&x);for(int i=1;i<=x/2;i++){if(i%2==0&&(x-i)%2==0){printf("YES");return 0;}}printf("NO");}總結
以上是生活随笔為你收集整理的C语言题目集-分西瓜的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++函数题-牛牛与好数
- 下一篇: c语言题目集-田队写长单词