汇编语言,试编制一个比赛得分程序。

汇编语言,试编制一个比赛得分程序。,第1张

ASSUME CS:CODE, DS:DATA

DATA 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

----------------------------------

#include "stdafx.h"

#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])

{

int i,temp,j

int k[11]

float sum=0

for(i=0i<10i++)

{

printf("请输入第%d位评委打分:\n",i+1)

scanf("%d",&k[i])

}

for(i=1i<10i++)

for(j=0j<10-ij++)

{

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

{

temp=k[j]

k[j]=k[j+1]

k[j+1]=temp

}

}

for(i=0i<10i++)

{

printf("%d ",k[i])

sum=sum+k[i]

}

printf("\n")

sum=sum-k[0]-k[9]

printf("除掉一个最高分和除掉一个最低分,最后平均分为:%1.2f",sum/10)

getchar()

getchar()

return 0

}


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存