码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 3785 找寻大富翁

时间:2019-06-06 09:22:24      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:str   can   空格   int   lse   strong   names   name   没有   

2019-06-06

08:30:03

坚持!!!

做这些水题,都觉得心累,特别是HDU的题,我PE了3发??

输出每行末尾没有空格,诶……

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int a[100005];
 4 int main()
 5 {
 6     int n, m;
 7     while(~scanf("%d %d", &n, &m))
 8     {
 9         if(n == 0 && m == 0)
10         {
11             break;
12         }
13         for (int i = 0; i < n; i++)
14         {
15             scanf("%d", &a[i]);
16         }
17         sort(a, a + n);
18         for (int i = n - 1,j =0 ; i >= 0 && j < m ; i--, j++)
19         {
20             if(j == m - 1)
21                 cout << a[i] ;
22             else
23                 cout << a[i] << " ";
24         }
25         cout << endl;
26     }
27     return 0;
28 }

 

HDU 3785 找寻大富翁

标签:str   can   空格   int   lse   strong   names   name   没有   

原文地址:https://www.cnblogs.com/Artimis-fightting/p/10983012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!