杭电ACM2023为什么wa,
写的可能比较乱,帮忙看下#include<stdio.h>#include<malloc.h>intmain(void){intn,m,i,j,t,x;double**a...
写的可能比较乱,帮忙看下
# include <stdio.h>
# include <malloc.h>
int main(void)
{
int n,m,i,j,t,x;
double ** a;
double s;
double k[5];
while(scanf("%d%d",&n,&m) != EOF)
{
a = (double **)malloc(sizeof(double *)*n);
for(i = 0;i < n;i ++)
a[i] = (double *)malloc(sizeof(double)*m);
for(i = 0;i < n;i ++)
for(j = 0;j < m;j ++)
scanf("%lf",&a[i][j]);
for(i = 0;i < n;i ++)
{
for(j = 0,s = 0;j < m;j ++)
s+=a[i][j];
s = s / m;
i!=n-1?printf("%.2f ",s):printf("%.2f\n",s); //学生平均成绩
}
for(j = 0;j < m;j ++)
{
for(i = 0,k[j] = 0;i < n;i ++)
k[j] += a[i][j];
k[j] = k[j]/n;
j!=m-1?printf("%.2f ",k[j]):printf("%.2f\n",k[j]);
}
for(i = 0,x = 0;i < n;i ++)
{
for(j = 0,t = 0;j < m;j ++)
{
if(a[i][j] > k[j])
t ++;
if(t == m) x++;
}
}
printf("%d\n\n",x);
for(i = 0;i < n;i ++)
free(a[i]);
}
return 0;
} 展开
# include <stdio.h>
# include <malloc.h>
int main(void)
{
int n,m,i,j,t,x;
double ** a;
double s;
double k[5];
while(scanf("%d%d",&n,&m) != EOF)
{
a = (double **)malloc(sizeof(double *)*n);
for(i = 0;i < n;i ++)
a[i] = (double *)malloc(sizeof(double)*m);
for(i = 0;i < n;i ++)
for(j = 0;j < m;j ++)
scanf("%lf",&a[i][j]);
for(i = 0;i < n;i ++)
{
for(j = 0,s = 0;j < m;j ++)
s+=a[i][j];
s = s / m;
i!=n-1?printf("%.2f ",s):printf("%.2f\n",s); //学生平均成绩
}
for(j = 0;j < m;j ++)
{
for(i = 0,k[j] = 0;i < n;i ++)
k[j] += a[i][j];
k[j] = k[j]/n;
j!=m-1?printf("%.2f ",k[j]):printf("%.2f\n",k[j]);
}
for(i = 0,x = 0;i < n;i ++)
{
for(j = 0,t = 0;j < m;j ++)
{
if(a[i][j] > k[j])
t ++;
if(t == m) x++;
}
}
printf("%d\n\n",x);
for(i = 0;i < n;i ++)
free(a[i]);
}
return 0;
} 展开
展开全部
#include<iostream>
using namespace std;
int main()
{
int a[50][5],i,j,k,n,m;
double b[5],c;
while(cin>>n>>m)
{
k=0;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
cin>>a[i][j];
for(i=0;i<n;i++)
{
c=0;
for(j=0;j<m;j++)
c+=a[i][j];
printf("%.2lf",c/m);
if(i!=n-1)
cout<<" ";
}
cout<<endl;
for(j=0;j<m;j++)
{
c=0;
for(i=0;i<n;i++)
c+=a[i][j];
b[j]=c/n;
printf("%.2lf",c/n);
if(j!=m-1)
cout<<" ";
}
cout<<endl;
for(i=0;i<n;i++)
{
k++;
for(j=0;j<m;j++)
if(b[j]>a[i][j])
{
k--;break;
}
}
cout<<k<<endl<<endl;
}
}
using namespace std;
int main()
{
int a[50][5],i,j,k,n,m;
double b[5],c;
while(cin>>n>>m)
{
k=0;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
cin>>a[i][j];
for(i=0;i<n;i++)
{
c=0;
for(j=0;j<m;j++)
c+=a[i][j];
printf("%.2lf",c/m);
if(i!=n-1)
cout<<" ";
}
cout<<endl;
for(j=0;j<m;j++)
{
c=0;
for(i=0;i<n;i++)
c+=a[i][j];
b[j]=c/n;
printf("%.2lf",c/n);
if(j!=m-1)
cout<<" ";
}
cout<<endl;
for(i=0;i<n;i++)
{
k++;
for(j=0;j<m;j++)
if(b[j]>a[i][j])
{
k--;break;
}
}
cout<<k<<endl<<endl;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询