汇编语言的编程题::
编写一个判断闰年的程序,输入具体年份,可以输出本年是否问为闰年的提示信息、急用!!!
汇编语言的编程题::
编写一个判断闰年的程序,输入具体年份,可以输出本年是否问为闰年的提示信息、急用!!!
汇编-判断闰年:
data segment ;定义数据段
infon db 0dh,0ah,'请输入一个年份: $'
Y db 0dh,0ah,'这是闰年! $'
N db 0dh,0ah,'这不是闰年! $'
w dw 0
buf db 8
db ?
db 8 dup(?)
data ends
stack segment stack
db 200 dup(0)
stack ends
code segment
assume ds:data,ss:stack,cs:code
start:mov ax,data
mov ds,ax
lea dx,infon ;在屏幕上显示提示信息
mov ah,9
int 21h
lea dx,buf ;从键盘输入年份字符串
mov ah,10
int 21h
mov cl, [buf+1]
lea di,buf+2
call datacate
call ifyears
jc a1
lea dx,n
mov ah,9
int 21h
jmp exit
a1: lea dx,y
mov ah,9
int 21h
exit: mov ah,4ch
int 21h
datacate proc near;
push cx;
dec cx
lea si,buf+2
tt1: inc si
loop tt1
;lea si,cx[di]
pop cx
mov dh,30h
mov bl,10
mov ax,1
l1: push ax
sub byte ptr [si],dh
mul byte ptr [si]
add w,ax
pop ax
mul bl
dec si
loop l1
ret
datacate endp
ifyears proc near
push bx
push cx
push dx
mov ax,w
mov cx,ax
mov dx,0
mov bx,4
div bx
cmp dx,0
jnz lab1
mov ax,cx
mov bx,100
div bx
cmp dx,0
jnz lab2
mov ax,cx
mov bx,400
div bx
cmp dx,0
jz lab2
lab1: clc
jmp lab3
lab2: stc
lab3: pop dx
pop cx
pop bx
ret
ifyears endp
code ends
end start
import java.util.Scanner;
public class Run
public static void main(String []args)
{
Scanner input=new Scanner(System.in);
System.out.println("请输入年份:");
int year=input.nextInt();
if(year%4==0&&year%400!=0||(year%400==0))
{
System.out.println(yrae+"年是润年");
}
else
System.out.println(year+"年是平年");
}