标签:double 基本 out pen 输入输出 code color a.out 用法
#include "stdafx.h" #include <stdio.h> int main() { FILE *fin,*fout; fin = fopen("data.in", "rb"); fout = fopen("data.out", "wb"); int x, n = 0, min, max, s = 0; fscanf(fin, "%d", &x); min = max = x; s += x; n++; while (fscanf(fin, "%d", &x) == 1) { if (x < min) min = x; if (x > max) max = x; n++; } fprintf(fout, "%d %d %.3f\n", min, max, (double)s / n); fclose(fin); fclose(fout); return 0; }
声明两个变量fin和fout,使输入流源和输出流目标定向为文件,其余用法和scanf,printf类似
标签:double 基本 out pen 输入输出 code color a.out 用法
原文地址:https://www.cnblogs.com/ZengWeiHao/p/10295726.html