dap an 6 asm
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
M1 db 13,10,'Hay vao so luong thanh phan : $'
M2 db 13,10,'a[$'
M3 db '] = $'
M4 db 13,10,'Tong day la : $'
M5 db 13,10,'Gia tri bieu thuc la : $'
M6 db 13,10,'Tiep tuc chuong trinh ( C/K ) ? $'
DauCham db '.$'
Array dw 100 dup(?)
.Code
Main :
mov ax,@data
mov ds,ax
;clrscr
HienString M1
call Vao_So_N
cmp ax,0
je Nhay
jmp Continue
Nhay :
jmp Finish
Continue :
mov dx,ax ; dx = so luong
xor si,si ; si = STT
mov cx,ax
lea bx , Array
Nhap :
HienString M2
mov ax,si
call Hien_So_N
HienString M3
call Vao_So_N
mov [bx],ax
inc si
add bx,2
loop Nhap
HienString M4
lea bx , Array
mov cx,dx
mov ax,[bx]
dec cx
Tong :
add bx,2
add ax,[bx]
loop Tong
call Hien_So_N
HienString M5
mov bx,dx
xor dx,dx
div bx
call Hien_So_N
and dx,dx
jz Finish
HienString DauCham
mov cx,2
mov si,10
Chia :
mov ax,dx
mul si
div bx
call Hien_So_N
and dx,dx
jz Finish
loop Chia
HienString M6
mov ah,1
int 21h
or al,20h
cmp al,'c'
jne Finish
jmp Main
Finish:
mov ah,4ch
int 21h
Include C:\TASM\INCLUDE\Lib2.asm
End Main
2a:
odel small
.Stack 100h
.Data
Extrn _n : WORD , _d : WORD , _u1 : WORD
.Code
Public @CapSoCong$qv
@CapSoCong$qv PROC
mov cx, _n
mov ax, _u1
mov bx, _d
dec cx
mov dx,ax
Tong :
add dx,bx
add ax,dx
loop Tong
ret
@CapSoCong$qv Endp
End
2c:
#include<conio.h>
#include<iostream.h>
int n;
extern int CapSoCong();
int d;
int u1;
void main(void)
{
clrscr();
cout<<"Nhap so luong thanh phan : ";
cin>>n;
cout<<"
Nhap cong sai d : ";
cin>>d;
cout<<"
Nhap gia tri dau cua cap so cong : ";
cin>>u1;
cout<<"
Tong cap so cong la : "<<CapSoCong();
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top