欢迎来到牛牛题库网 牛牛题库官网
logo

未知题型

下列给定程序中函数fun()的功能是:将长整型数中每一位上为奇数的数依次取出,构成一个新数放在冲。高位仍在高位,低位仍在低位。例如当s中的数为87653142时,t中的数为7531。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conlo.h>
void fun (long s, long *t)
{int d;
long s1=1;
/*************found**************/
t=0;
while(s>0)
{ d=s%10;
/*************found**************/
if(d%2==0)
{*t=d*s1+*t;
s1*=10;
}
s/=10;
}
}
main()
{long s, t;
clrscr();
printf('/nPlease enter s:');scanf('%ld',&s);
fun(s,&t);
printf('The result is:%ld/n',t);
}

A.h>
B.h>
【参考答案】

(1)错误:t=0; 正确:*t=0;(2)错误:if(d%2==0) 正确:if(d%2!=0)
(1)错误:......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)

点击查看答案

相关考题

微信小程序免费搜题
微信扫一扫,加关注免费搜题

微信扫一扫,加关注免费搜题