编程题: 请编写函数fun,其功能是:将两个两位数的正证书a、b合并形成一个证书放在c中。合并的方式是:将a数的十位和个位数依次放在c数的千位和十位上,b数的十位和个位数依次放在c数的百位和个位上。
例如,当a=45,b=12,调用该项函数后,c=4152。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
参考答案:
编程题:#include <conio.h>
#include <stdio.h>
void fun (int a, int b ,long *c)
{
}
main ()
{
int a,b;
long c;
FILE *out;
printf ("Input a, b:");
scanf("%d%d", &a, &b);
fun (a, b, &c);
printf ("The result is: %d\n", c);
out=fopen ("out.dat", "w");
for (a = 10; a < 20; a++)
{
fun(a, 109-a, &c);
fprintf(out, "%d\n", c);
}
fclose (out );
}
输入fun函数:void fun (int a, int b, long*c)
{
*c=(a/10)*1000+(b/10)*100+(a%10)*10+b%10;
}