欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

编程判断输入整数的正负性和奇偶性。 **输入格式要求:“%d“ 提示信息:“Input m:“ **输出格式要求: 如果是负偶数,则输出“%d is a negative even\n“ 如果是负奇

程序员文章站 2022-07-15 12:21:13
...

编程判断输入整数的正负性和奇偶性。
**输入格式要求:"%d" 提示信息:“Input m:”
**输出格式要求:
如果是负偶数,则输出"%d is a negative even\n"
如果是负奇数,则输出"%d is a negative odd\n"
如果是正偶数,则输出"%d is a positive even\n"
如果是正奇数,则输出"%d is a positive odd\n"
如果是0,则输出"%d is zero. It is an even\n"
程序运行示例1:
Input m:6↙
6 is a positive even
程序运行示例2:
Input m:0↙
0 is zero. It is an even

#include<stdio.h>
int main()
{
	 int x;
	 printf("Input m:");
	 scanf("%d",&x);
	 if(x!=0)
	 {
	 	if(x<0)
	 	{
	 	if(x%2==0)	
	 	{
	 	  printf("%d is a negative even\n",x);	
		 }
		 if(x%2!=0)	
	 	{
	 		printf("%d is a negative odd\n",x);
		 }
		 }
		 	if(x>0)
	 	{
	  	  	if(x%2==0)	
	 	{
	 	printf("%d is a positive even\n",x);	
		 }
		 if(x%2!=0)	
	 	{
	 		printf("%d is a positive odd\n",x);
		 }
		 }
		 
	 }
	 else
	 {
	 printf("%d is zero. It is an even\n",x);
	  } 
}
相关标签: cqupt c语言