HDU:2023 求平均成绩

时间:2021-09-11 03:39:30
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,n,j,x,m,sum1,sum2,flag;
    double s1[60],s2[60];
    int a[100][100];
    while(scanf("%d %d",&n,&m)!=EOF){
        sum1=sum2=0;
        for(i=0;i<n;i++){
            sum1=0;
            for(j=0;j<m;j++){
                scanf("%d",&a[i][j]);
                sum1+=a[i][j];
            }
            s1[i]=(double)sum1;
        }
        for(j=0;j<m;j++){
            for(i=0;i<n;i++){
                sum2+=a[i][j];
            }
            s2[j]=sum2;
            sum2=0;
        }
        x=0;
        for(i=0;i<n;i++){
            flag=1;
            for(j=0;j<m;j++){
                if((a[i][j]*1.0)<(s2[j]/n)){
                    flag=0;
                    break;
                }else{flag=1;}
            }
            if(flag==1)x++;
        }

        for(i=0;i<n;i++)
            if(i==n-1)printf("%.2lf",s1[i]/m);
            else printf("%.2lf ",s1[i]/m);
        printf("\n");

        for(i=0;i<m;i++)
            if(i==m-1)printf("%.2lf",s2[i]/n);
            else printf("%.2lf ",s2[i]/n);
        printf("\n");

        printf("%d\n\n",x);

    }
    return 0;
}