输入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)
exit(0);
}
printf(" 输入 n : ");
scanf("%d",&n);
printf(" 输入实数: ");
scanf("%lf",&x);
2
for(i=0; i<n-1;i++){
scanf("%lf",&x);
if(a<x) a=x;
if (b>x) 3
}
4 ;
(1) A 、 ”c:\\abc.txt","w" B 、 ”c:\\abc.txt","r" C 、 ”c:\\abc.txt","write" D 、 ”c:\\abc.txt","read"
(2) A 、 a=b=0; B 、 a=b=x; C 、 a=0;b=x; D 、 a=x;b=0;
(3) A 、 x=b; B 、 b=x; C 、 a=b; D 、 b=a;