|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
int main()
{
int weight;
scanf("%d",&weight);
if(weight==2||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.");
}
#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.");
}
感觉这俩段差不多来着
- if(weight==2||weight%4==0)
复制代码
如果是 2 或 4的倍数 则打印 yes
- if(weight%2==0&&weight!=2)
复制代码
如果是 2 的倍数且不等于 2 则打印yes
能看出区别了么?
第一个取值范围: 2 4 8 12 16 20 ...
第二个取值范围: 4 6 8 10 12 14 ...
|
|