用C语言程序系统设计:武汉晴川学院十佳歌手比赛成绩系统。设计要求:1、建立成绩输入,按照“去掉一个最低分,去掉一个最高分求平均成绩的”计算方法计算排名成绩;2、输出选手信息(包括选手编号、各评委给分、最后成绩);3、输出排名信息(对2中已有信息进行排名、输出名次);4、根据选手编号进行成绩以及相关信息的查询。设计说明:1、程序的主函数实现:输入选手和评委个数(选手不超过20人,评委在3~6人之间)输入每一位评委为选手的打分情况并计算选手最终得分,利用switch语句调用3个自定义函数以及退出;2、自定义函
时间: 2024-03-05 11:53:42 浏览: 79
数1:计算选手最终得分,去掉一个最低分和一个最高分,求平均分;
3、自定义函数2:输出选手信息;
4、自定义函数3:输出排名信息,对选手成绩进行排名,输出名次;
5、自定义函数4:根据选手编号进行成绩以及相关信息的查询。
以下是一个简单的C语言程序系统设计,实现武汉晴川学院十佳歌手比赛成绩系统:
```c
#include <stdio.h>
#define MAX_JUDGE_NUM 6
#define MAX_PLAYER_NUM 20
float calculateScore(float score[], int judgeNum);
void printPlayerInfo(int playerId, float score[], float finalScore);
void printRankingInfo(int playerId[], float score[], float finalScore[], int playerNum);
int searchPlayer(int playerId[], int playerNum, int searchId);
int main() {
int judgeNum, playerNum, choice;
float score[MAX_JUDGE_NUM], finalScore[MAX_PLAYER_NUM];
int playerId[MAX_PLAYER_NUM];
printf("请输入评委人数(3-6):");
scanf("%d", &judgeNum);
printf("请输入选手人数(不超过20人):");
scanf("%d", &playerNum);
printf("请输入选手编号和打分:\n");
for (int i = 0; i < playerNum; i++) {
printf("选手编号:");
scanf("%d", &playerId[i]);
printf("打分:");
for (int j = 0; j < judgeNum; j++) {
scanf("%f", &score[j]);
}
finalScore[i] = calculateScore(score, judgeNum);
}
while (1) {
printf("\n请选择:\n");
printf("1. 输出选手信息\n");
printf("2. 输出排名信息\n");
printf("3. 根据选手编号查询\n");
printf("4. 退出\n");
scanf("%d", &choice);
switch (choice) {
case 1:
for (int i = 0; i < playerNum; i++) {
printPlayerInfo(playerId[i], score, finalScore[i]);
}
break;
case 2:
printRankingInfo(playerId, score, finalScore, playerNum);
break;
case 3:
int searchId;
printf("请输入选手编号:");
scanf("%d", &searchId);
int index = searchPlayer(playerId, playerNum, searchId);
if (index == -1) {
printf("没有找到该选手!\n");
} else {
printPlayerInfo(playerId[index], score, finalScore[index]);
}
break;
case 4:
return 0;
default:
printf("选择无效!\n");
}
}
}
float calculateScore(float score[], int judgeNum) {
float minScore = score[0], maxScore = score[0], totalScore = score[0];
for (int i = 1; i < judgeNum; i++) {
if (score[i] < minScore) {
minScore = score[i];
}
if (score[i] > maxScore) {
maxScore = score[i];
}
totalScore += score[i];
}
return (totalScore - minScore - maxScore) / (judgeNum - 2);
}
void printPlayerInfo(int playerId, float score[], float finalScore) {
printf("选手编号:%d\n", playerId);
printf("打分:");
for (int i = 0; i < MAX_JUDGE_NUM; i++) {
printf("%.1f ", score[i]);
}
printf("\n");
printf("最终得分:%.1f\n", finalScore);
}
void printRankingInfo(int playerId[], float score[], float finalScore[], int playerNum) {
int ranking[MAX_PLAYER_NUM];
for (int i = 0; i < playerNum; i++) {
ranking[i] = 1;
for (int j = 0; j < playerNum; j++) {
if (finalScore[j] > finalScore[i]) {
ranking[i]++;
}
}
}
printf("排名信息:\n");
printf("名次\t选手编号\t最终得分\n");
for (int i = 0; i < playerNum; i++) {
printf("%d\t%d\t\t%.1f\n", ranking[i], playerId[i], finalScore[i]);
}
}
int searchPlayer(int playerId[], int playerNum, int searchId) {
for (int i = 0; i < playerNum; i++) {
if (playerId[i] == searchId) {
return i;
}
}
return -1;
}
```
该程序实现了计算选手最终得分、输出选手信息、输出排名信息、根据选手编号进行成绩以及相关信息的查询等功能。其中,calculateScore函数计算选手最终得分,printPlayerInfo函数输出选手信息,printRankingInfo函数输出排名信息,searchPlayer函数根据选手编号进行成绩以及相关信息的查询。程序通过循环实现了用户选择不同功能的操作。
阅读全文