Http://acm.ocrosoft.com/problem.php?cid=1316&pid=8
Title Description
A town in Hangzhou, Zhejiang has a total of n individuals, please find the town's former m monopoly.
Input
The input contains multiple sets of test cases.
Each use case first contains 2 integers n (0<n<=100000) and M (0<m<=10), Where: N is the number of people in town, M is the number of millionaires that need to be found, and the next line is to enter the wealth value of N people in the town.
N and m at 0 indicate the end of the input.
Output
Please output Wuzhen former M monopoly property number, property of the row front, if the monopoly less than m, then all output, each group of output accounted for a row.
Sample input
3 11 6 25 32 3 4 5 60 0
Sample output
66 5 4
Code:
#include <bits/stdc++.h>using namespace Std;const int maxn = 1e5 + 10;int N, m;double num[maxn];bool cmp (int x, int Y) { return x > y;} int main () { while (~scanf ("%d%d", &n, &m)) { if (! N &&! M) break; for (int i = 1; I <= N; i + +) scanf ("%lf", &num[i]); Sort (num + 1, num + 1 + N, CMP); for (int i = 1; I <= M; i + +) { cout << num[i]; printf ("%s", I! = M?) "": "\ n");} } return 0;}
Ocrosoft Contest1316-The road to the programming of ~~~~~ the third issue I: Looking for a Millionaire