"Algorithmic Competition Introduction Classic" chapter II 2.3

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.