标签:for ret return include txt out code span problem
小技巧 判断 全部为零 用sign和所有元素依次取或
排除最大项和最小项 直接排序后取中间的四个元素
http://poj.org/problem?id=3507
1 #include <iostream>
2 #include <stdio.h>
3 #include <algorithm>
4 using namespace std;
5
6 int main()
7 {
8 freopen("in.txt", "r", stdin);
9 int a[6];
10 double sum;
11 bool sign = 0;
12 while (1)
13 {
14 sign = 0;
15 sum = 0;
16 for (int i = 0; i < 6; i++)
17 {
18 cin >> a[i];
19 sign |= a[i];
20 }
21 if (!sign) break;
22 sort(a, a+6);
23 for (int i = 1; i < 5; i++)
24 {
25 sum += a[i];
26 }
27 cout << sum / 4 << endl;
28 }
29 return 0;
30 }
标签:for ret return include txt out code span problem
原文地址:http://www.cnblogs.com/oscar-cnblogs/p/6288178.html