注意:
当前路径跟程序应该位于同一目录。
1.重定向版
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LOCAL
using namespace std;
int main()
{
#ifdef LOCAL
freopen("date.in.txt","r",stdin);
freopen("date.out.txt","w",stdout);
#endif
return 0;
}
2.fopen版
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
FILE *fin,*fout;
fin=fopen("date.in.txt","rb");
fout=fopen("date.out.txt","wb");
// int x,n=0,mini=9999,maxi=-9999,s=0;
while(fscanf(fin,"%d",&x)!=EOF)
{
// s+=x;
// mini=min(mini,x);
// maxi=max(maxi,x);
// n++;
}
fprintf(fout,"%d %d %.3f\n",mini,maxi,(double)s/n);
fclose(fin);
fclose(fout);
return 0;
}