#include
main()
{
int x,y;
printf("Please input a integer:"); /*输入一个整数!*/
scanf("%d",x);
if(x<0)
printf("It's a negative number!"); /*输入的数是负数!*/
else
printf("It's a positive number!"); /*输入的数是正数!*/
y=x%2;
if(0==y)
printf("It's a even number!"); /*输入的数是偶数!*/
else
printf("It's a odd number!"); /*输入的数是奇数!*/
}
右边的是注释!
void main()
{
int num;
scanf("%d",&num);
if(num>0)
{printf("该数是正数\n;}
else
{printf("该数是负数\n;}
num=num%2;
if(num==0)
{prin订鸡斥课俪酒筹旬船莫tf("该数是偶数\n;}
else
{printf("该数是奇数\n;}
#include
main()
{
int x,y;
printf("Please input a integer:"); /*输入一个整数!*/
scanf("%d",x);
if(x<0)
printf("It's a negative number!"); /*输入的数是负数!*/
else
printf("It's a positive number!"); /*输入的数是正数!*/
y=x%2;
if(0==y)
printf("It's a even number!"); /*输入的数是偶数!*/
else
printf("It's a odd number!"); /*输入的数是奇数!*/
}
右边的是注释!
1 #include
2
3 int main(int argc, char* argv[])
4 {
5 int a;
6
7 scanf("%d", &a);
8 if (0 == a % 2) printf("%d是偶数\n", a);
9 else printf("%d是奇数\n", a);
10
11 if (a < 0) printf("%d是负数\n", a);
12 else printf("%d是正数\n", a);
13
14 return 0;
15 }
正负判断最高位,1为负,0为正
奇偶判断最低位,1为奇,0为偶