Procedure 2-7
Omitted
Procedure 2-8
1 #defineLOCAL2#include <stdio.h>3 #defineINF 1000000004 intMain ()5 {6 #ifdef LOCAL7Freopen ("data.in","R", stdin);8Freopen ("Data.out","W", stdout);9 #endif //LOCALTen intX, n =0, Min = INF, max =-inf, s =0; One while(SCANF ("%d", &x) = =1) A { -s + =x; - if(x < min) min =x; the if(x > Max) max =x; - /* - printf ("x =%d, Min =%d, max =%d\n", x, Min, max); - */ +n++; - } +printf"%d%d%0.3lf", Min, Max, (Double) s/n); A return 0; at}
Exercise 2-9
1#include <stdio.h>2 #defineINF 1000000003 intMain ()4 {5FILE *fin, *Fout;6Fin = fopen ("data.in","RB");7Fout = fopen ("Data.out","WB");8 intX, n =0, Min = INF, max =-inf, s =0;9 while(FSCANF (FIN,"%d", &x) = =1)Ten { Ones + =x; A if(x < min) min =x; - if(x > Max) max =x; -n++; the } -fprintf (Fout,"%d%d%0.3lf", Min, Max, (Double) s/n); - fclose (Fin); - fclose (fout); + return 0; -}
Exercise 2-8, 2-9 file operation, is also a recent paper to be familiar with some ...
Introduction to Algorithmic Competition Chapter II 2.3