如何用C语言编写一个程序,使其输入的密码以*号的形式显示在屏幕。
2个回答
展开全部
C语言的太没挑战性了
汇编语言的的
.486
DATA SEGMENT USE16
SECRET1 DB '12345'
SECRET2 DB 7 DUP(?)
MESG1 DB 'Please enter the secret!You have $'
NUM DB 33H
DB ' times!',0DH,0AH,'$'
MESG2 DB 0DH,0AH,'The secret is wrong!',0DH,0AH,'$'
MESG3 DB 0DH,0AH,'Welcome!',0DH,0AH,'$'
DATA ENDS
CODE SEGMENT USE16
ASSUME CS:CODE,DS:DATA,ES:DATA
BEG: MOV AX,DATA
MOV DS,AX
MOV ES,AX
AGAIN:
CMP NUM,30H
JE EXIT
MOV AH,9
MOV DX,OFFSET MESG1
INT 21H
MOV AH,9
MOV DX,OFFSET NUM
INT 21H
MOV BX,OFFSET SECRET2
NEXT1: MOV AH,7
INT 21H
MOV [BX],AL
INC BX
CMP AL,0DH
JE NEXT2
MOV AH,2
MOV DL,'*'
INT 21H
CALL NEXT1
NEXT2: MOV SI,OFFSET SECRET1
MOV DI,OFFSET SECRET2
MOV CX,5
CLD
REPE CMPSB
JNZ WRONG
JMP RIGHT
WRONG: MOV AH,9
MOV DX,OFFSET MESG2
INT 21H
DEC NUM
CALL AGAIN
RIGHT: MOV AH,9
MOV DX,OFFSET MESG3
INT 21H
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END BEG
汇编语言的的
.486
DATA SEGMENT USE16
SECRET1 DB '12345'
SECRET2 DB 7 DUP(?)
MESG1 DB 'Please enter the secret!You have $'
NUM DB 33H
DB ' times!',0DH,0AH,'$'
MESG2 DB 0DH,0AH,'The secret is wrong!',0DH,0AH,'$'
MESG3 DB 0DH,0AH,'Welcome!',0DH,0AH,'$'
DATA ENDS
CODE SEGMENT USE16
ASSUME CS:CODE,DS:DATA,ES:DATA
BEG: MOV AX,DATA
MOV DS,AX
MOV ES,AX
AGAIN:
CMP NUM,30H
JE EXIT
MOV AH,9
MOV DX,OFFSET MESG1
INT 21H
MOV AH,9
MOV DX,OFFSET NUM
INT 21H
MOV BX,OFFSET SECRET2
NEXT1: MOV AH,7
INT 21H
MOV [BX],AL
INC BX
CMP AL,0DH
JE NEXT2
MOV AH,2
MOV DL,'*'
INT 21H
CALL NEXT1
NEXT2: MOV SI,OFFSET SECRET1
MOV DI,OFFSET SECRET2
MOV CX,5
CLD
REPE CMPSB
JNZ WRONG
JMP RIGHT
WRONG: MOV AH,9
MOV DX,OFFSET MESG2
INT 21H
DEC NUM
CALL AGAIN
RIGHT: MOV AH,9
MOV DX,OFFSET MESG3
INT 21H
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END BEG
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询