用汇编语言编写“计算1+2*3+3*4...+N*(N+1)且N*(N+I)<200”的程序

2024-12-20 21:21:29
推荐回答(2个)
回答1:

code segment
assume cs:codestart:
mov cx,1
mov ax,2
next:
cmp cx,200
jge exit
inc al
mov bl,al
dec bl
mul bl
add cx,ax
mov ax,0
mov al,bl
inc al
jmp next
exit:
mov al,bl AAM
mov dl,ah
mov bl,al
add dl,30h
mov ah,2
int 21h
mov dl,bl
add dl,30h
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start

回答2:

program sum;
var s,i:longint;
begin
s:=1;
i:=2;
while i*(i+1)<200 do
begin
s:=s+i*(i+1);
inc(i);
end;
writeln(s);
end.