等级考试上机题目(上课用)(6)
时间:2026-01-17
时间:2026-01-17
}
main()
{int a,b; long c;
void NONO ();
printf("Input a, b:");
scanf("%d,%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i, a,b ; long c ;
rf = fopen("in.dat", "r");
wf = fopen("out.dat","w");
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b);
fun(a, b, &c);
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c);
}
fclose(rf);
fclose(wf);
}
第3套
1.程序填空题
#include <math.h>
#include <stdio.h>
int fun(char *fname)
{FILE *fp; int i,n; float x;
if((fp=fopen(fname, "w"))==NULL) return 0;
6
下一篇:LED电子屏招标公告