#define PW_CNT 3
#define XS_CNT 1
int main(int argc, char *argv[])
{
float score[XS_CNT][PW_CNT] = {{0.0f}}
float sum[XS_CNT] = {0.0f}
float avg[XS_CNT] = {0.0f}
int i = 0, j = 0
for (i = 0 i < XS_CNT i++)
{
for (j = 0 j < PW_CNT j++)
{
printf("请输入第%d位评委对第%d位选手的评分:\n", j+1, i+1)
scanf("%f", &score[i][j])
sum[i] += score[i][j]
}
avg[i] = sum[i]/PW_CNT
printf("第%d位选手的总成绩:%.2f 平均成绩:%.2f\n", i+1, sum[i], avg[i])
}
return 0
}
刚刚的回答我又改了下,这次能改选手和评委数了。
果然是两个人的提问,问题竟然一模一样...
这是我上一个的回答
#include <stdio.h>int main()
{
float x[8]={9.2,9.5,9.0,8.9,9.3,9.5,9.1,9.0}
float max, min
int i
float avg = 0
max = min = x[0]
for (i = 0i <8i++)
{
if (x[i] >max)
{
max = x[i]
}
if (x[i] <min)
{
min = x[i]
}
avg += x[i]
}
avg = (avg - max - min) / 6
printf("the avrage sorce is: %f.\n", avg)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)