几道C语言填空和编程题,请高手帮忙,万分感激!!!

2024-12-17 09:36:16
推荐回答(2个)
回答1:

(1)
int sum(int a,int b)
{
return a+b;
}
(2)不知是取出偶数还是取出十位,千位上的数,故写两个程序
long takeout(long a)
{
int b,i=1;
long sum=0;
while(a!=0)
{
b=a%10;
if(b%2==0)
{
sum=b*i+sum;
i=i*10;
}
a=a/10;
}
return sum;
}

long takeout(long a)
{
int b,i=1,k=0;
long sum=0;
while(a!=0)
{
b=a%10;
k++;
if(k%2==0)
{
sum=b*i+sum;
i=i*10;
}
a=a/10;
}
return sum;
}

汗,太多了,不想做了,都不难的,自己多想想吧

回答2:

void main()
int a b sum
sum=a+b