竞赛中常见的输入输出格式

样例输入:
8
2 8 3 5 1 7 3 6
4
-4 6 10 0
样例输出:
Case 1: 1 8 4.375
Case 2: -4 10 3.000

#include 
#define INF 1000000000

int main()
{
    int x, n = 0, ***kase = 0;***
    while(scanf("%d", &n) == 1 ***&& n***){
        ***int s = 0;***
        int min = INF;
        int max = INF;
        for(int i = 0; i < n; i++){
            scanf("%d", &x);
            s += x;
            if(x < min) min = x;
            if(x > max) max = x;
        }
        ***if(kase) printf("\n");***
        printf("Case %d; %d %d %.3f\n", ***++kase***, min, max, (double)s/n);
    }
    return 0;
}
  1. 用kase变量输出Case n:
  2. 判断是否结束用 && n

你可能感兴趣的:(算法)