2013计算机等级考试二级C语言试题及答案12

全国等级考试资料网 2023-11-02 17:23:29 92
  填空题:
请补充fun函数,该函数的功能是:把一个证书转换成字符串,并到序保存在字符数组str中。例如:当n=12345678时,str=“87654321”。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
参考答案:
填空题:
#include
#include
#define N 80
char str[N];
void fun(long int n)
{
int i = 0;
while (___1___)
{
str[i] = ___2___;
n /= 10;
i++;
}
___3___;
}
main()
{
long int n = 1234567;
printf("****** the origial data ******** ");
printf("n=%ld", n);
fun(n);
printf(" %s", str);
}
第一处填空:n>0或0 相关资料

相关阅读