当前位置: > 2. 编写一个函数fun,然后设计主函数调用函数fun.函数fun的功能是:计算正整数num的各位上的数字之积....
题目
2. 编写一个函数fun,然后设计主函数调用函数fun.函数fun的功能是:计算正整数num的各位上的数字之积.
例如,若输入:252,则输出应该是:20.若输入:202,则输出应该是:0

提问时间:2021-01-17

答案
#include
#include
int fun(int x){
int r=1,d,c;
while (1){
d = x % 10;
r = r * d;
x = (x - d) / 10;
if (x == 0) break;
}
return r;
}
main( ){
int num;
printf("input num ");
scanf("%d",&num);
printf("%d",fun(num));
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.