DE 1 ASM
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
Title1 db 13,10,'| CHUONG TRINH |$'
Title2 db 13,10,'| TINH THANH PHAN CHAN LE CUA 1 DAY SO NGUYEN |$'
Title3 db 13,10,' ---------------------------------------------$'
M1 db 13,10,'>>Hay vao thanh phan so luong cua day : $'
M2 db 13,10,'a[$'
M3 db '] = $'
M4 db 13,10,'So luong cac thanh phan chan cua day so nguyen la : $'
M5 db 13,10,'So luong cac thanh phan le cua day so nguyen la : $'
M6 db 13,10,'Tiep tuc chuong trinh ( C/K ) ? $'
M7 db 13,10,'Chuc nang khong ton tai . Moi chon lai !$'
Array dw 100 dup(?)
.Code
Main :
mov ax,@data
mov ds,ax
;clrscr
HienString Title1
HienString Title2
HienString Title3
HienString M1
call Vao_So_N
cmp ax,1
jb Hoi
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
xor ax,ax
mov si,dx
XuLy:
mov dx,[bx]
shr dx,1
jc SoLe
inc ax
SoLe:
add bx,2
loop XuLy
call Hien_So_N
HienString M5
sub si,ax
mov ax,si
call Hien_So_N
Hoi :
HienString M6
mov ah,1
int 21h
or al,20h
cmp al,'c'
jz Nhay
cmp al,'k'
jz Finish
HienString M7
jmp Hoi
Nhay:
jmp Main
Finish:
mov ah,4ch
int 21h
Include C:\TASM\INCLUDE\Lib2.asm
End Main
.Model small
.Data
Extrn _Array:DWORD,_n:WORD
.Code
Public @ChanLe$qv
@ChanLe$qv PROC
mov bx,OFFSET _Array
mov ax,SEG _Array
mov es,ax
mov cx,_n
xor ax,ax
XuLy:
mov dx,es:[bx]
shr dx,1
jc SoLe
inc ax
SoLe:
add bx,2
loop XuLy
ret
@ChanLe$qv Endp
End
#include<iostream.h>
#include<conio.h>
int n;
int Array[100];
extern int ChanLe();
void main(void)
{
PS :
clrscr();
char answer;
int i;
cout<<">>Hay vao thanh phan so luong cua day : ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"a["<<i<<"] = ";
cin>>Array[i];
}
cout<<"So luong cac thanh phan chan cua day so nguyen : "<<ChanLe();
cout<<"
So luong cac thanh phan le cua day so nguyen : "<<n-ChanLe();
cout<<"
Tiep tuc chuong trinh (C/K) ? ";
answer = getch();
if(answer=='c')
goto PS;
}
Bạn đang đọc truyện trên: Truyen247.Pro