#include <stdio.h>
void add(int a)
{
int m = 0, n = 0, k = 0, sum = 0;
m = a/100;
sum = sum + m;
n = (a - m * 100)/10;
sum = sum + n;
k = a - m * 100 - n * 10;
sum = sum + k;
printf ("这个三位整数各位数之和是:%d", sum);
printf ("\n");
}
void count(int a[4])
{
int i = 0,m = 0, n = 0;
for (;i < 4;i++)
{
if (0 == (a[i] % 2))
m = m + 1;
else
n = n + 1;
}
printf ("偶数有%d个\n",m);
printf ("奇数有%d个\n",n);
}
int main(void)
{
int i = 0, n, a[4];
printf ("请输入一个三位整数\n");
scanf ("%d",&n);
add(n);
printf ("请输入整形数组数据\n");
for (;i < 4;i++)
{
scanf ("%d",&a[i]);
getchar();
}
count(a[4]);
return 0;
}
时间紧迫最后一个就不写了.这两个还是可以运行的.