输入n和n个实数,找出他们的最大值和最小值,并将最大值和最小值输出到文件c:\abc.txt中。
运行示例:
输入 n : 5 ↙
输入实数: 4 56.8 78.0 13 -12 ↙
程序运行结束 !
【程序】
#include <stdio.h>
#include <stdlib.h>
void main( )
int i,n;
FILE *p;
if ((p=fopen( 1 ))==NULL) 【 A 、 ”c:\\abc.txt","w" B 、 ”c:\\abc.txt","r" C 、 ”c:\\abc.txt","write" D 、 ”c:\\abc.txt","read" 】
exit(0);
}
printf(" 输入 n : ");
scanf("%d",&n);
printf(" 输入实数: ");
scanf("%lf",&x);
2 【 A 、 a=b=0; B 、 a=b=x; C 、 a=0;b=x; D 、 a=x;b=0; 】
for(i=0; i<n-1;i++){
scanf("%lf",&x);
}
4 ; 【 A 、 fprintf(p,"max=%.1f,min=%.1f\n", a,b); B 、 fprintf(abc.txt,"max=%.1f,min=%.1f\n", a,b); C、 printf(p,"max=%.1f,min=%.1f\n", a,b); D 、 printf(abc.txt,"max=%.1f,min=%.1f\n", a,b); 】
fclose(p);
}