演讲比赛评分系统c语言表达
时间: 2024-12-03 07:13:37 浏览: 5
设计一个演讲比赛评分系统的C语言版本通常会涉及到几个关键部分:定义评分标准、输入选手信息、计算总分以及输出结果。下面是一个简化版的示例:
```c
#include <stdio.h>
#include <stdlib.h>
// 定义评分标准结构体
typedef struct {
char category[50];
int weight;
} ScoreCategory;
// 评分项目数组
ScoreCategory categories[] = {
{"内容", 40},
{"表达能力", 30},
{"仪态", 20},
{"创新思维", 10}
};
// 总分计算函数
int calculateTotalScore(int *scores, int numCategories) {
int total = 0;
for (int i = 0; i < numCategories; i++) {
total += scores[i] * categories[i].weight;
}
return total;
}
int main() {
int numJudges;
printf("请输入评委人数:");
scanf("%d", &numJudges);
// 假设每个评委有四项打分
int judgeScores[numJudges][4];
for (int j = 0; j < numJudges; j++) {
for (int k = 0; k < 4; k++) {
printf("请输入第%d位评委对第%d项的分数:", j+1, k+1);
scanf("%d", &judgeScores[j][k]);
}
}
int totalScores[numCategories];
for (int i = 0; i < 4; i++) {
int sum = 0;
for (int j = 0; j < numJudges; j++) {
sum += judgeScores[j][i];
}
totalScores[i] = sum / numJudges;
}
int overallScore = calculateTotalScore(totalScores, sizeof(categories) / sizeof(ScoreCategory));
printf("参赛者的总分为:%d\n", overallScore);
return 0;
}
```
阅读全文