C语言中如何判断整数(5位数)的每一个数字是奇数还是偶数
#include<stdio.h>intmain(){inta,b,c,d,e;while(10000){printf("pleaseinputthenumber:\n"...
#include <stdio.h>
int main()
{
int a,b,c,d,e;
while(10000)
{
printf("please input the number:\n");
scanf("%d",&a,&b,&c,&d,&e);
if(a&1)
{
printf("%d is ODD\n",a);
}
else
{
printf("%d is EVEN\n",a);
}
if(b&1)
{
printf("%d is ODD\n",b);
}
else
{
printf("%d is EVEN\n",b);
}
if(c&1)
{
printf("%d is ODD\n",c);
}
else
{
printf("%d is EVEN\n",c);
}
if(d&1)
{
printf("%d is ODD\n",d);
}
else
{
printf("%d is EVEN\n",d);
}
if(e&1)
{
printf("%d is ODD\n",e);
}
else
{
printf("%d is EVEN\n",e);
}
}
return 0;
}
答案要像:
例如:98765
9 is ODD
8 is EVEN
7 is ODD
6 is EVEN
5 is ODD 展开
int main()
{
int a,b,c,d,e;
while(10000)
{
printf("please input the number:\n");
scanf("%d",&a,&b,&c,&d,&e);
if(a&1)
{
printf("%d is ODD\n",a);
}
else
{
printf("%d is EVEN\n",a);
}
if(b&1)
{
printf("%d is ODD\n",b);
}
else
{
printf("%d is EVEN\n",b);
}
if(c&1)
{
printf("%d is ODD\n",c);
}
else
{
printf("%d is EVEN\n",c);
}
if(d&1)
{
printf("%d is ODD\n",d);
}
else
{
printf("%d is EVEN\n",d);
}
if(e&1)
{
printf("%d is ODD\n",e);
}
else
{
printf("%d is EVEN\n",e);
}
}
return 0;
}
答案要像:
例如:98765
9 is ODD
8 is EVEN
7 is ODD
6 is EVEN
5 is ODD 展开
展开全部
#include <stdio.h>
int main()
{
int n, a, b, c, d, e;
scanf("%d", &n);
a = n / 10000; //万位
b = n % 10000 / 1000; //千位
c = n % 1000 / 100; //百位
d = n % 100 / 10; //十位
e = n % 10; //个位
printf("%d是%s数\n", a, a & 1 ? "奇" : "偶");
printf("%d是%s数\n", b, b & 1 ? "奇" : "偶");
printf("%d是%s数\n", c, c & 1 ? "奇" : "偶");
printf("%d是%s数\n", d, d & 1 ? "奇" : "偶");
printf("%d是%s数\n", e, e & 1 ? "奇" : "偶");
return 0;
}
展开全部
#include<iostream>
#include<stdio.h>
int main()
{
int a , b[5]= {0} , i ;
puts("输入一个五位数吧。。。");
scanf("%d" , &a);
for( i = 0 ; i< 5 ; i++ )
{
if(a&1){b[i] = 1;}
a = a / 10;
}
for( i = 4 ; i >=0 ; i--)
{
if(b[i] == 1)
{
printf("_奇_");
}
else
{
printf("_偶_");
}
}
return 0 ;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询