【程序设计】
时间限制 1 s
空间限制 125 MB
/*-------------------------------------------------------
【程序设计】
---------------------------------------------------------
题目:编写函数fun,其功能是:将a、b两个两位正整数合并成一个新的整数放在c中。
合并的方式是:将a中的十位和个位数依次放在变量c的千位和十位上,b中的十
位和个位数依次放在变量c的个位和百位上。
例如:当a=45,b=12,调用该函数后c=4251。
注意:请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入
你编写的若干语句。
-------------------------------------------------------*/
#include <stdio.h>
void wwjt ( );
void fun(int a, int b, long *c)
{
/*Program*/
/********** End **********/
}
void main()
{
int a,b; long c;
printf("Input a, b:");
scanf("%d%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
wwjt( );
}
void wwjt ( )
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
FILE *in, *out ;
int i, a,b ; long c ;
in=fopen("in.dat","r");
if(in==NULL)
{
printf("Please Verify The Currernt Dir..It May Be Changed");
}
out=fopen("out.dat","w");
if(out==NULL)
{
printf("Please Verify The Current Dir.. It May Be Changed");
}
for(i = 0 ; i < 10 ; i++)
{
fscanf(in, "%d,%d", &a, &b) ;
fun(a, b, &c) ;
fprintf(out, "a=%d,b=%d,c=%ld\n", a, b, c) ;
}
fclose(in) ;
fclose(out) ;
}
代码
编辑器
请先登录后再提交代码。