P5710 【深基3.例2】数的性质(分支结构)
题目描述
一些数字可能拥有以下的性质:
性质 1:是偶数;
性质 2:大于 4 且不大于 12。
小A 喜欢这两个性质同时成立的数字;Uim 喜欢这至少符合其中一种性质的数字;八尾勇喜欢刚好有符合其中一个性质的数字;正妹喜欢不符合这两个性质的数字。
输入格式
输入一个数字 x(0\le x \le 1000)x(0≤x≤1000)
输出格式
输出这 4 个人是否喜欢这个数字,如果喜欢则输出1,否则输出0,用空格分隔。
输入输出样例
输入
12
输出
1 1 0 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main ()
{
int n;
scanf("%d",&n);
if(n%2==0&&n>4&&n<=12)
printf("1 ");
else
printf("0 ");
if(n%2==0||n>4&&n<=12)
printf("1 ");
else
printf("0 ");
if(n%2!=0&&n>4&&n<=12||n%2==0&&n<=4&&n>12)
printf("1 ");
else
printf("0 ");
if(n%2!=0&&n<=4&&n>12)
printf("1 ");
else
printf("0 ");
}

浙公网安备 33010602011771号