下列给定程序中函数fun的功能是:从低位开始取出整型变量s中偶数位上的数,依次构成一个新数放在t中。例如

#include<iostream.h>void fun(int s){ int t=1;s/=10; t=s%10;while(s>0){ s=s/100;t=s%10+10*t;}return t;}void main(){ int s; cin>>s; int t=fun(s); cout<<”t= “<<t<<endl;}是一道改错题,请大家帮忙!
2026年09月26日 02:59
有1个网友回答
网友(1):

函数返回值错误,不是 void,应该是int

修改码:
#include

int fun(int s)
{
int t=1;s/=10;
t=s%10;
while(s>0)
{
s=s/100;t=s%10+10*t;
}
return t;
}

void main()
{
int s;
cin>>s;
int t=fun(s);
cout<<"t="<
}