C语言程序 评委打分

C语言程序 评委打分,第1张

#include "stdio.h"const int LEN=30,M=100,N=100typedef struct { int num//抽签号码 char name[LEN]//姓名 float score/察历昌/得分 } playerplayer players[M]//歌手信息int a[M][N]//评委打分信息int m,n//歌手和评委数量//输入歌手信息和评委打分信息void input(void){ int i,jprintf("歌手数量:") scanf("%d",&m)printf("评委数量:") scanf("%d",&n) for(i=0i<mi++) { players[i].num=i+1 printf("第%d个歌手的姓名:",i+1) scanf("%d",&players[i].name) printf("第%d个歌手的评委打分:",i+1) for(j=0j<nj++) {scanf("%d",&a[i][j]) } }}//求平均值(去掉一个最高分,去掉一个最低高分,求出其余n-2个分数的平均值 void calculate(void){ float max,minint i,j for(i=0i<mi++) { max=min=players[i].score=a[i][0] for(j=1j<nj++) {players[i].score+=a[i][j] if(max<a[i][j]){ max=a[i][j] }if(min>a[i][j]){ min=a[i][j] } } if(n>2) {players[i].score=(players[i].score-max-min)/(n-2) } else if(n>0) {players[i].score/=n } } }//对各个选手的得分,用冒泡法排序 //如果用快速排序或堆排序,把这段改写一下就行了void sort(void){ int i,jfor(i=0i<m-1i++) { for(j=m-1j>ij--) {if(players[j].score>players[j-1].score){ player tmptmp=players[j]players[j]=players[j-1]players[j-1]=tmp } } } }//显示所有原始数据void show_origin(void){ int i,jprintf("\n")for(i=0i<mi++) { printf("抽签号码:%d ",players[i].num) printf("姓名:%d ",players[i].name) printf("评委打分:") for(j=0j<nj++) {printf("%d ",a[i][j]) } printf("\n")} }//显示所有歌手的信息 void show_player(void){ int iprintf("\n")for(i=0i<mi++) { printf("抽签号码:%d ",players[i].num) printf("姓名:%d ",players[i].name) printf("得分:%f\n"败扒,players[i].score) } }//显示获奖歌手的烂御信息 int main() { input()show_origin()calculate()show_player()sort()return 0}

#include <stdio.h>

#include<string.h>

void main()

{

int i,j,m,n

float num,xgrade[100],max,min,pgrade[100],pdis[100]

char str[10],xname[100][10],pname[100][10]

printf("请输入评委人数:")

scanf("%d",&m)

printf("\n请分别输入评委姓名:\n")

for(i=0i<mi++)

{

scanf("%s",&pname[i])//评委姓名

pgrade[i]=0//评委给的分

pdis[i]=0//评委给分和最后结果的差距

}

printf("\n请输入选手人数:")

scanf("%d",&n)

printf("\辩睁n请分别输入选手姓名:\n")

for(i=0i<ni++)

{

scanf("%s",&xname[i])//选手姓名

xgrade[i]=0//选手成绩

}

for(i=0i<ni++)

{

max=0min=10//评委给选手的最大最小成绩

printf("\n请给选手%s打分!",xname[i])

for(j=0j<mj++)

{

printf("\n%s老师给的分数为:",pname[j])

scanf("%f",&pgrade[j])

xgrade[i]+=pgrade[j]//加到该选手的总分数中

if(max<pgrade[j])

max=pgrade[j]

if(min>pgrade[j])

min=pgrade[j]

}

xgrade[i]=(xgrade[i]-max-min)/(m-2)//最后成绩为总成绩-最高分-最低分,然后平均

for(j=0j<mj++)//算出每个评委本次评袭雀分和最终成绩的差,加到pdis中保存起来

{

pdis[j]+=pgrade[j]>xgrade[i]?(pgrade[j]-xgrade[i]):(xgrade[i]-pgrade[j])

}

}

for(i=0i<n-1i++)

for(j=0j<n-1-ij++)

if(xgrade[j]<xgrade[j+1])

{

strcpy(str,xname[j])

strcpy(xname[j],xname[j+1])

strcpy(xname[j+1],str)

num=xgrade[j]

xgrade[j]=xgrade[j+1]

xgrade[j+1]=num

}

printf("\n选手按名次排名为:\n")

printf("选手名\t得分\n")

for(i=0i<ni++)

printf("%s\t%f\n",xname[i],xgrade[i])

for(i=0i<m-1i++)

for(j=0j<m-1-ij++)

if(pdis[j]>pdis[j+1])

{

strcpy(str,pname[j])

strcpy(pname[j],pname[j+1])

strcpy(pname[j+1],str)

num=pdis[j]

pdis[j]=pdis[j+1]

pdis[j+1]=num

}

printf("\n评委按名次排名为:\n")

printf("评委名\t差分拍灶早\n")

for(i=0i<mi++)

printf("%s\t%f\n",pname[i],pdis[i])

}

vae.la

窗体上放个隐仔按纽,代码如下

Private Sub Command1_Click()

Dim s(9) As Double, i As Integer, k As Double, max As Double, min As Double

For i = 0 To 9

s(i) = InputBox("请打出一个分数")

Next i

If s(0) <s(1) Then min = s(0) Else min = s(1)

If min >s(2) Then min = s(2)

If min >s(3) Then min = s(3)

If min >s(4) Then min = s(4)

If min >祥陆 s(5) Then min = s(5)

If min >s(6) Then min = s(6)

If min >s(7) Then min = s(7)

If min >s(8) Then min = s(8)

If min >s(9) Then min = s(9)

If s(0) >s(1) Then max = s(0) Else max = s(1)

If max <s(2) Then max = s(2)

If max <s(3) Then max = s(3)

If max <s(4) Then max = s(4)

If max <s(5) Then max = s(5)

If max <s(6) Then max = s(6)

If max <s(7) Then max = s(7)

If max <s(8) Then max = s(8)

If max <s(9) Then max = s(9)

k = (s(0) + s(1) + s(2) + s(3) + s(4) + s(5) + s(6) + s(7) + s(8) + s(9) - max - min) / 8

Print "平谨携顷均分为:" &k

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12438871.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存