hdu-1031-Design T-Shirt
来源:互联网 发布:文华财经交易模型源码 编辑:程序博客网 时间:2024/05/21 19:18
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
double a[500][500];
struct in
{
double x;
int y;
}b[500];
int cmp1(const in &a,const in &b)
{
//struct in *c=(in *)a;
// struct in *d=(in *)b;
return a.x>=b.x;//c->x<d->x;
}
int cmp2(const in &a,const in &b)
{
//struct in *c=(in *)a;
//struct in *d=(in *)b;
return b.y<a.y;//d->y-c->y;
}
int main()
{
int n,m,k,i,j;
double sum;
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%lf",&a[i][j]);
for(j=0;j<m;j++)
{
for(sum=0.0,i=0;i<n;i++)
sum+=a[i][j];
b[j].x=sum/n;
b[j].y=j+1;
}
sort(b,b+m,cmp1);
sort(b,b+k,cmp2);
for(i=0;i<k-1;i++)
printf("%d ",b[i].y);
cout<<b[k-1].y<<endl;
}
return 0;
}
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
double a[500][500];
struct in
{
double x;
int y;
}b[500];
int cmp1(const in &a,const in &b)
{
//struct in *c=(in *)a;
// struct in *d=(in *)b;
return a.x>=b.x;//c->x<d->x;
}
int cmp2(const in &a,const in &b)
{
//struct in *c=(in *)a;
//struct in *d=(in *)b;
return b.y<a.y;//d->y-c->y;
}
int main()
{
int n,m,k,i,j;
double sum;
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%lf",&a[i][j]);
for(j=0;j<m;j++)
{
for(sum=0.0,i=0;i<n;i++)
sum+=a[i][j];
b[j].x=sum/n;
b[j].y=j+1;
}
sort(b,b+m,cmp1);
sort(b,b+k,cmp2);
for(i=0;i<k-1;i++)
printf("%d ",b[i].y);
cout<<b[k-1].y<<endl;
}
return 0;
}
0 0
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- hdu(1031)Design T-Shirt
- hdu 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- hdu-1031-Design T-Shirt
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- hdu 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU 1031 Design T-Shirt
- HDU-1031-Design T-Shirt
- Cause: java.io.UTFDataFormatException: Invalid byte 3 of 3-byte UTF-8 sequence. 解决办法
- Activiti工作流简介
- NC(NetCat)命令详解
- HDU 3549 Flow Problem
- 64位的linux装的hadoop是32位的,需要手工编译
- hdu-1031-Design T-Shirt
- 蛋疼的ViewPager+竖直SeekBar实现过程(1)竖直SeekBar实现
- 斥巨资打造鹰目LED联播网
- stm32 利用Flash进行储存数据
- 给IT新人的15点建议:苦逼程序员的辛酸反省与总结
- 从4.0.4 master分支移植到4.0.4_r1
- Mozilla / Firefox / Gecko in VB.NET,geckofx 1.9 vb.net中使用方法
- 鸟哥教会我的一些命令
- 如何将decimal保留小数位后两位,使用四舍五入,利用时间差计算部分时间