【HDU 3785】【水题】寻找大富翁

  水题

#include "stdio.h"
#include "algorithm"
using namespace std;
int cmp(int a,int b)
{
	return a>b;
}
int main(int argc, char const *argv[])
{
	int n,m;
	while(~scanf("%d %d",&n,&m) && (n+m))
	{
		int a[100005];
		for (int i = 0; i < n; ++i)
		{
			scanf("%d",&a[i]);
		}
		sort(a,a+n,cmp);
		for (int i = 0; i < m; ++i)
		{
			if(i)
				printf(" ");
			printf("%d",a[i]);
		}
		printf("\n");
	}
	return 0;
}


你可能感兴趣的:(c,水题)