0
点赞
收藏
分享

微信扫一扫

freopen()函数的使用

hoohack 2022-02-25 阅读 28
#define LOCAL	
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define INF 1000000000
int main(){
	#ifdef LOCAL
		freopen("D:\\算法\\data.txt","r",stdin);
		freopen("D:\\算法\\data2.txt","w",stdout);
	#endif
	int x,n=0,max=-INF,min=INF,s=0;
	while(scanf("%d",&x)==1){
		s+=x;
		if(x<min) min=x;
		if(x>max) max=x;
		n++;
	}
	printf("%d %d %.3f\n",min,max,(double)s/n);
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
	
}

在这里插入图片描述

在这里插入图片描述

举报

相关推荐

0 条评论