#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
ASSUME CS:CODE, DS:DATADATA SEGMENT
STRING DB 13, 10, 'Please iuput number_1 : $'
STRING2 DB 13, 10, 'The average is : $'
NUM DB 7 DUP (?)
MAX DB 0
MIN DB 255
N_SUMDW ?
NUM_XDB ?
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV CX, 7
MOV SI, 0
IN_X:
MOV DX, OFFSET STRING
MOV AH, 9 显示字符串
INT 21H
CALL INPUT
MOV NUM[SI], BL
CALL OUTPUT
INC SI
INC STRING + 24
LOOP IN_X
--------------------------
CALL SUM
MOV N_SUM, BX
MOV AL, MAX
MOV AH, 0
SUB BX, AX
MOV AL, MIN
MOV AH, 0
SUB BX, AX
MOV AX, 5
XCHG AX, BX
DIV BL
MOV NUM_X, AH
MOV AH, 0
XCHG AX, BX
MOV DX, OFFSET STRING2
MOV AH, 9 显示字符串
INT 21H
CALL OUTPUT
CALL OUTPUT2
EXIT:
MOV AH, 4CH
INT 21H
----------------------------------
SUM:
MOV BX, 0
MOV CX, 7
MOV SI, 0
LP1:
MOV AL, NUM[SI]
CMP AL, MAX
JBLP2
MOV MAX, AL
LP2:
CMP AL, MIN
JAHE
MOV MIN, AL
HE:
MOV AH, 0
ADD BX, AX
INC SI
LOOP LP1
RET
----------------------------------
INPUT:
PUSH CX
MOV BX, 0
MOV CX, 2
IN_1:
MOV AH, 1
INT 21H
CMP AL, 13
JZIN_END
CMP AL, '0'
JBIN_1
CMP AL, '9'
JAIN_1
AND AL, 0FH
MOV AH, 0
XCHG AX, BX
MOV DL, 10
MUL DL
ADD AX, BX
XCHG AX, BX
LOOP IN_1
IN_END:
POP CX
RET
----------------------------------
OUTPUT2:
MOV AH, 02H
MOV DL, '.' 小数点
INT 21H
MOV AL, NUM_X
MOV BL, 10
MUL BL
MOV BL, 5
DIV BL
MOV NUM_X, AH
ADD AL, '0'
MOV DL, AL
MOV AH, 2
INT 21H
MOV AL, NUM_X
MOV BL, 10
MUL BL
MOV BL, 5
DIV BL
MOV NUM_X, AH
ADD AL, '0'
MOV DL, AL
MOV AH, 2
INT 21H
RET
----------------------------------
OUTPUT:
MOV AX, BX
MOV BL, 10
DIV BL
ADD AX, 3030H
MOV DX, AX
MOV AH, 2
INT 21H
MOV DL, DH
INT 21H
RET
----------------------------------
CODE ENDS
END START
----------------------------------
Dim a(10) As IntegerPrivate Sub Command1_Click()
For i = 1 To 10
a(i) = InputBox("请输入第" &i &"个分数")
Text1.Text = Text1.Text &Str(a(i))
Next i
End Sub
Private Sub Command2_Click()
Max = a(1)
Min = a(1)
For i = 1 To 10
s = s + a(i)
If Max <a(i) Then Max = a(i)
If Min >a(i) Then Min = a(i)
Next i
s = (s - Max - Min) / 8
Text2.Text = Max
Text3.Text = Min
Text4.Text = s
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub Command4_Click()
End
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)