📄 modi76.c
字号:
/*
下列给定程序中函数fun的功能是:将长整型数中每一位上为偶数的数依次取出,构成一个新数放在tK 。高位仍在高位,低位仍在低位。例如,当s中的数为87653142时,t中的数为8642。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
*/
#include <conio.h>
#include <stdio.h>
/**********found************/
void fun (long s, long *t)
{ int d;
long s1=1;
*t = 0;
while ( s>0)
{ d=s%10;
/**********found************/
if (d%2=0)
{ *t=d* s1+ *t;
s1 *= 10;
}
/**********found************/
s \= 10;
}
}
main()
{ long s, t;
clrscr();
printf("\nPlease enter s:"); scanf("%1d", &s);
fun(s, &t);
printf("The result is: %1d\n", t);
}
/*
答案:
第2行 int d; long d;
第7行 if(d%2=0) if(d%2==0)
第11行 s\=10; s/=10;
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -