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;
}
       
       
      
0 0
原创粉丝点击