从键盘输入1-5中的一个数分别在屏幕上显示1st,2st,3st,4st,5st,其他显示*
发布网友
发布时间:2022-04-22 20:29
我来回答
共3个回答
热心网友
时间:2023-10-27 20:29
; multi-segment executable file template.
data segment
; add your data here!
str db 10,13,0
chr db ?,"st",10,13,9
pkey db "press any key...$"
errmsg db 10,13,"Only 0-5 are acceptable, press any key...$"
ends
stack segment
dw 128 p(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; Read a key from Keyboard
mov ah, 1
int 21h
; check the key
cmp al, '0'
jc err
cmp al, '5'
jnbe err
mov chr, al
lea dx, str
jmp outmsg
err:
lea dx, errmsg
outmsg:
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
热心网友
时间:2023-10-27 20:29
code segment
assume cs:code
start:
mov ah,1
int 21h
cmp al,30h
jbe other
cmp al,36h
jae other
mov dl,al
mov ah,2
int 21h
mov dl,'s'
int 21h
mov dl,'t'
int 21h
jmp tj
other:
mov dl,'*'
mov ah,2
int 21h
tj:
mov ah,1
int 21h
mov ah,4ch
int 21h
code ends
end start
热心网友
时间:2023-10-27 20:30
#include<stdio. h>
void main()
{ int a;
scanf("%d",&a);
switch(a)
{
case 1:
case 2:
case 3:
case 4:
case 5:printf("1st,2st,3st,4st,5st\n");break;
default:printf("other!\n");break;
}