#include <stdio.h>#define SINGERS 6#define JUDGES 5typedef struct data{ int order char name[16] double score[JUDGES]} DATAint main( void ){ DATA student[SINGERS] int i, j for ( i = 0i <SINGERS++i ) { printf("Enter the name of singer %d: ",i+1) fflush(stdin) gets(student[i].name) printf("Enter %s\'s starting order: ",student[i].name) scanf("%d",&student[i].order) for ( j = 0j <JUDGES++j ) { printf("Enter score %d: ",j+1) scanf("%lf",&student[i].score[j]) } putchar('\n') } printf("\n\nName Order ") for ( i = 0i <JUDGES++i ) printf("Score%d ",i+1) putchar('\n') for ( i = 0i <SINGERS++i ) { printf("\n%-15s%-6d",student[i].name,student[i].order) for ( j = 0j <JUDGES++j ) { printf("%-7g",student[i].score[j]) }} puts("\n\nThank you!") getch() return 0}#include <stdio.h>
#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
}
刚刚的回答我又改了下,这次能改选手和评委数了。
果然是两个人的提问,问题竟然一模一样...
这是我上一个的回答
评论列表(0条)