/ 科创班 /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 256.0 KiB
#2 Wrong Answer 2ms 256.0 KiB
#3 Wrong Answer 2ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 2ms 256.0 KiB
#7 Runtime Error 5ms 256.0 KiB
#8 Accepted 2ms 256.0 KiB
#9 Accepted 2ms 256.0 KiB
#10 Accepted 2ms 256.0 KiB

代码

#include <stdio.h>
#define N 10
#define M 5

int n,m,r,c;
float score[N][M];
float a_stu[N],a_cour[M];

int main()
{
int i,j;
float h;
float s_var(void);
float highest();
void input_stu(void);
void aver_stu(void);
void aver_cour(void);

scanf("%d %d",&n,&m);

input_stu();
aver_stu();
aver_cour();
//printf("\n NO. cour1 cour2 cour3 cour4 cour5 aver\n");

for(i=0;i<n;i++) printf("%.2f ",a_stu[i]);
printf("\n");

for(j=0;j<m;j++) printf("%.2f ",a_cour[j]);
printf("\n");

h=highest();
printf("%.2f %d %d\n",h,r,c);

printf("%.2f",s_var());
return 0;
}

void input_stu(void)
{
int i,j;
for(i=0;i<n;i++)
{
//printf("\ninput score of student%2d:\n",i+1);
for(j=0;j<m;j++)
scanf("%f",&score[i][j]);
}
}

void aver_stu(void)
{
int i,j;
float s;
for(i=0;i<n;i++)
{for(j=0,s=0;j<m;j++)
s+=score[i][j];
a_stu[i]=s/(float)m;
}
}

void aver_cour(void)
{
int i,j;
float s;
for(j=0;j<m;j++)
{s=0;
for(i=0;i<n;i++)
s+=score[i][j];
a_cour[j]=s/(float)n;
}
}

float highest()
{
float high;
int i,j;
high=-1;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(score[i][j]>high)
{
high=score[i][j];
r=i+1;
c=j+1;
}
return(high);
}

float s_var(void)
{
int i;
float sumx,sumxn;
sumx=0.0;
sumxn=0.0;
for(i=0;i<n;i++)
{
sumx+=a_stu[i]*a_stu[i];
sumxn+=a_stu[i];
}
return (sumx/n-(sumxn/n)*(sumxn/n));
}

信息

递交者
类型
递交
题目
7.14学生成绩
题目数据
下载
语言
C
递交时间
2018-07-14 15:47:07
评测时间
2018-07-14 15:47:07
评测机
分数
60
总耗时
27ms
峰值内存
256.0 KiB