开始的时候一直执着于<abbr title="%4==0">这样</abbr>
#include<stdio.h> int main(){ int weight; scanf("%d",&weight); if(weight%4==0){ printf("YES, you can divide the watermelon into two even parts."); }else{ printf("NO, you can't divide the watermelon into two even parts."); } }
最后发现,原题是不要两边对半分的,没有考虑到。所以其实除了2,只需要 %2
就足够啦。
#include<stdio.h> int main(){ int weight; scanf("%d",&weight); if (weight%2==0&&weight!=2){ printf("YES, you can divide the watermelon into two even parts."); }else{ printf("NO, you can't divide the watermelon into two even parts."); } }