HDU 1031 Design T-Shirt
2017-04-26 15:00
423 查看
查看原题
题意
输入nmk,n个人分别对m样东西进行打分,从中选出k样得分最高的,再对这k样东西的序号从大到小输出思路
代码
#include <iostream> #include <algorithm> #include <string.h> using namespace std; struct n{ int id;float score=0; }num[300]; bool cmp(struct n a, struct n b){ return a.score>b.score; } bool cmpid(struct n a, struct n b){ return a.id>b.id; } int main(int argc, char *argv[]) { int n,m,k; while(cin>>n>>m>>k){ memset(num,0, sizeof(num)); float temp; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>temp; num[j].score+=temp; num[j].id=j; } } sort(num+1,num+m+1,cmp); sort(num+1,num+k+1,cmpid); for(int i=1;i<k;i++){ cout<<num[i].id<<" "; } cout<<num[k].id<<endl; } return 0; }
相关文章推荐
- HDU 1031 Design T-Shirt(水~)
- HDU—— 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- HDU1031 Design T-Shirt(java)
- HDU 1031 Design T-Shirt 选前k大
- HDU 1031 Design T-Shirt(结构体2级排序)
- HDU 1031 Design T-Shirt
- HDU 1031 - Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU-1031- Design T-Shirt(c++ && 简单模拟)
- 杭电 HDU 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- hdu_1031_Design T-Shirt(模拟)
- HDU1031 Design T-Shirt (二级排序)
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- hdu1031 Design T-Shirt 解题报告 sort的使用
- HDU 1031 Design T-Shirt 模拟 水题