原题链接:http://acm.uestc.edu.cn/problem.php?pid=1043

输出前m大的数据

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<functional>
 5 using namespace std;
 6 int queue[1000005];
 7 int main()
 8 {
 9     int n,m,k;
10     while(scanf("%d%d",&n,&m)!=EOF)
11     {
12         for(k=0;k<n;k++)
13         scanf("%d",&queue[k]);
14         sort(queue,queue+n,greater<int>());
15         for(k=0;k<m;k++)
16         printf("%d ",queue[k]);
17         printf("\n");
18     }
19     return 0;
20 }
21                      

 

相关文章:

  • 2021-12-06
  • 2021-10-13
  • 2021-07-23
  • 2021-10-31
  • 2021-12-07
  • 2021-09-04
  • 2021-07-26
  • 2022-02-04
猜你喜欢
  • 2022-12-23
  • 2021-10-06
  • 2021-12-29
  • 2022-01-20
  • 2022-02-22
  • 2021-06-16
  • 2021-09-12
相关资源
相似解决方案