标签:file fopen 读取文件 读取 scan include max fprintf ble
#include <iostream>
#include <stdio.h>
#define INF 100000000000
using namespace std;
// 文件输入输出小应用
int main()
{
FILE* fin, * fout;// 定义两个文件类型指针
fin = fopen("data.in", "r"); //读取文件
fout = fopen("data.out", "w"); // 写入文件
int x, n = 0, min = INF, max = -INF, s = 0;
while (fscanf(fin, "%d", &x) == 1) {
s += x;
if (x < min)
min = x;
if (x > max)
max = x;
n++;
}
fprintf(fout, "%d %d %.3f", min, max, (double)s / n);
fclose(fin);
fclose(fout);
return 1;
}
标签:file fopen 读取文件 读取 scan include max fprintf ble
原文地址:https://www.cnblogs.com/TyranRex/p/12181452.html