You are on page 1of 29

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.

com

Gii Bi Tp Tin Hc 11

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 1:

t s khi nim v lp trnh v ngn ng lp trnh

Bi tp

1. Ng i ta ph i xy d ng ngn ng l p trnh b c cao v - Ngn ng l p trnh b c cao g n gi v i t nhin hn, thu n ti n cho ng o ng i l p trnh. - Ngn ng l p trnh b c cao ni chung khng ph thu c vo lo i my, cng m t chng trnh c th th c hi n nhi u my khc nhau. - Chng trnh vi t b ng ngn ng b c cao d hi u, d hi u ch nh v d nng c p hn. - Ngn ng l p trnh b c cao cho php lm vi c v i nhi u ki u d li u v cch t ch c d li u a d ng, thu n ti n cho m t thu t ton. 2. Chng trnh d ch l chng trnh c bi t, c ch c nng chuy n i chng trnh c vi t trn ngn ng l p trnh b c cao thnh chng trnh th c hi n c trn my tnh. 3. - Bin d ch: duy t, ki m tra, pht hi n l i, xc nh chng trnh ngu n c d ch c khng. D ch ton b chng trnh ngu n thnh m t chng trnh ch c th th c hi n trn my v c th lu tr l i s d ng v sau khi c n. - Thng d ch: l n l t d ch t ng cu l nh ra ngn ng my r i th c hin ngay cu l nh v a d ch c ho c thng bo l i n u khng d ch c. 4. Cc i m khc nhau gi a tn dnh ring v tn chu n: tn dnh ring khng c dng khc v i ngha xc nh, tn chu n c th dng v i ngha khc. 5. ng: tamgiac, bai5a, xemxonxiu_ngu... 6. C: 6,23 6.23 E: A20 tn cha c gi tr G: 4 + 6 H: C CI: TRUE true l h ng logic.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 2:

hng trnh n gin

Bi Thc Hnh S 1 -----------------***** *****---------------------------------*****----------------S khc nhau gi a h ng c t tn v tn bi n: Gi tr c a h ng c t tn khng thay i khi th c hi n chng trnh cn gi tr c a bi n c th thay i t i t ng th i i m th c hi n chng trnh. 2. Khai bo bi n nh m nh ng m c ch sau: - Xc nh ki u c a bi n. Trnh d ch s bi t cch t ch c nh ch a gi tr c a bi n. - a tn bi n vo danh sch cc i t ng c chng trnh qu n l. - Trnh d ch bi t cch truy c p gi tr c a bi n v p d ng thao tc thch h p cho bi n. 3. integer, real, extended, longint. 4. D 5. C
1. 6. (1 + z ) * ( x + y / z ) /(a 1 /(1 + x * x * x * x)) 2a 7. a) ; b) abc ; c) b ; d) 2b b 2 ac a +b 8.

a) program bai8a; crt; uses crt; var x,y:real; kt:boolean; begin clrscr; write('Nhap x: ');readln(x); write('Nhap y: ');readln(y); kt:=false; if ((y<1) or (y=1)) and ((y>abs(x)) or (y=abs(x))) then kt:=true; if kt then write('Diem vua nhap thuoc phan gach cheo')

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

thuoc'); else write('Khong thuoc'); readln end. end.

V D

b) program bai8; uses crt; var x,y:real; kt:boolean; begin clrscr; write('Nhap x: ');readln(x); write('Nhap y: ');readln(y); kt:=false; if (abs(y)<=1) and (abs(x)<=1) then kt:=true; gach if kt then write('Diem vua nhap thuoc phan gach cheo') else write('Khong thuoc'); readln end. end.

V D

Bi 9. rogram bai9; uses crt; const pi= 3.1416; var a,s:real; begin clrscr; repeat write('Nhap ban kinh duong tron: '); readln(a); if a<0 then writeln('Nhap lai!'); until a>0; s:=(a*a*pi)/2; write('Dien write('Dien tichphan gach cheo: ',s:8:3);

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

readln end. end.

V D

Bi 10. program bai10; uses crt; const g= 9.8; var v, h:real; begin clrscr; repeat write('Nhap do cao: '); readln(h); if h<0 then writeln('Nhap lai!'); until h>0; v:=sqrt(2*g*h); toc: write('Van toc: ',v:8:3); readln end. end.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 3:

u trc r nhnh v lp

Bi Thc Hnh S 2 -----------------***** *****---------------------------------*****----------------1. SGK 2. Cu l nh ghp l m t cu l nh c h p thnh t nhi u cu l nh thnh ph n. Cu l nh ghp nh m th c hi n thao tc g m nhi u thao tc thnh ph n. M i thao tc thnh ph n ng v i m t cu l nh n ho c m t cu l nh ghp khc. Cu l nh ghp l m t trong cc y u t t o kh nng chng trnh c c u trc. Cc cu l nh t gi a begin v end; Bi 3. Program tong1a; Uses crt; Var S: real; a, N: integer; begin clrscr; write('Nhap a: ');readln(a); S:=1.0/a; N:=1; While n<=100 do Begin S:=S+1.0/(a+N); N:=N+1; N:=N+1; End; End; Writeln('Tong S la: ',S:8:4); Readln End. End.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi 4. . a) program bai4a; uses crt; var x, y, z:real; begin clrscr; write('nhap hai so x va y: '); if x*x+y*y<=1 then begin z:=(x*x+y*y); writeln('tong can tim: ',z:9); end; end; if (x*x+y*y>1) and (y>=x) then begin z:=(x+y); writeln('tong can tim: ',z:9); end; end; if (x*x+y*y>1) and (y<x) then begin z:=0.5; writeln('tong can tim: ',z); end; end; readln end. end.

readln(x,y);

V D
b) program bai4b; bai4b uses crt; var x,y,z,a,b,r:real; begin clrscr; write('Nhap x: ');readln(x); write('Nhap y: ');readln(y); write('Nhap toa do tam hinh tron: '); readln(a,b); write('Nhap ban kinh r: ');readln(r); sqrt(sqr(x-a)+sqr(xif sqrt(sqr(x-a)+sqr(x-b))<r then begin

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

z:=abs(x)+abs(y); writeln('Z= ',z:3:3); end else begin begin z:=x+y; writeln('Z= ',z:3:3); end; end; readln end. end.

V D

Bi 5. a) bai5a; Program bai5a; Uses crt; Const n=50; Var i: integer; Y:real; Begin Clrscr; for i:=1 to n do Y:=i/(i+1); ',y:9:3 :9:3); Write('Tong Y: ',y:9:3); Readln End. End.

V D

b) program bai5b; program bai5b; uses crt; var n:longint; e,sh:real; begin clrscr; sh:=1/2; n:=2;

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

e:=2+sh; sh>=2*1ewhile sh>=2*1e-16 do begin n:=n+1; sh:=sh*(1/n); e:=e+sh; end; end; writeln('Gia tri e(n) la: ',e:10:6); readln end. end.

V D
Bi 6. program Bai6; program Bai6; uses crt; var x, y:byte; begin clrscr; for x:=1 to 36 do for y:=0 to 20 do if (x+y=36) and (2*x+4*y=100) then begin writeln('Co ',x,' con Ga'); write('Co ',y,' con Cho'); end; end; readln end. end.

V D
Bi 7. Bai7; program Bai7; uses crt; var b, c, n:byte; begin begin clrscr; repeat write('Nhap tuoi write('Nhap tuoi (bif (b-c<25) or writeln('Du lieu

cha: ');readln(b); con: ');readln(c); (b<2*c) then khong hop le,nhap lai.');

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

(buntil (b-c>=25) and (b>=2*c); if b=2*c then writeln('Hien nay tuoi cha gap hai lan tuoi con.') else if b>2*c then ',bwriteln('Sau ',b-2*c,' nam tuoi cha se gap doi tuoi con'); readln end. end.

V D

Bi 8. program Bai8; Bai8; uses crt; var A, B, St, Luu :real; n:byte; begin clrscr; write('Nhap so tien gui: ');readln(a); write('Nhap write('Nhap so tien nhan: ');readln(b); luu:=A; n:=0; st:=a; while St<=B do begin St:=St+luu*0.003; =St+luu*0.003 St:=St+luu*0.003; n:=n+1; end; end; writeln('So thang can la: ',n); readln end. end.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 4:

iu d liu c cu trc

Bi Thc Hnh S 3 -----------------*****-------------------------------***** -----------------*****----------------Bi 1. program sum1; uses crt; const nmax=100; type Myarray=array[1..nmax] of integer; var A:myarray; s,n,i,k:integer; posi,neg:integer; begin clrscr; randomize; write('Nhap n: ');readln(n); A[i]:=random(300) [i]:=random(300)for i:=1 to n do A[i]:=random(300)-random(300); for i:=1 to n do write(A[i]:5); writeln; for i:=1 to n do if A[i]>0 then posi:=posi+1 else if A[i]<0 then neg:=neg+1; writeln('Co ',posi,' so duong va ',neg,' so am trong mang'); write('Nhap k: ');readln(k); s:=0; for i:=1 to n do if A[i] mod k = 0 then s:=s+A[i]; writeln('Tong can tinh la: ',s); readln end. end.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

V D

Bi ny cho k t qu ng u nhin nn k t qu c a cc b n c th khc. Bi 2. program mang2; uses crt; var A:array[1..100] of integer; n,i,j,max:integer; begin begin clrscr; write('Nhap so luong phan tu: ');readln(n); for i:=1 to n do begin write('Nhap phan tu thu ',i,': '); readln(a[i]); end; end; max:=a[1]; for i:=2 to n do a[i]>a[iif a[i]>a[i-1] then max:=A[i]; for j:=1 to n do if a[j]=max then nhat: writeln('chi so phan tu lon nhat: ',j); readln end. end.

V D

Ch : Cc b n s a l i chng trnh a ra k t qu h p l, cc ch s c a ph n t l n nh t cng n m trn m t dng.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi Thc Hnh S 4 -----------------***** *****---------------------------------*****----------------Bi 1. uses crt; var A:array[1..250] of integer; n,i,j,y,dem,t:integer; n,i,j,y,dem,t:integer; begin clrscr; randomize; write('Nhap n: ');readln(n); A[i]:=random(300)for i:=1 to n do A[i]:=random(300)-random(300); for i:=1 to n do write(A[i]:5); writeln; dem:=1; for j:=n downto 2 do jfor i:=1 to j-1 do if A[i]>A[i+1] then begin t:=a[i]; a[i]:=a[i+1]; A[i+1]:=t; dem:=dem+1; end; end; write('Sau khi dao ',dem,' lan'); for i:=1 to n do write(A[i]:7); writeln; readln end. end.

V D

Bi ny cho k t qu l ng u nhin.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi Thc Hnh S 5 -----------------***** *****---------------------------------*****----------------Bi 1. program xau; uses crt; var i, x:byte; S: string; kt:boolean; begin clrscr; write('Nhap xau: ');readln(s); x:=length(S); kt:=true; for i:=1 to x div 2 do S[i]<>S[xif S[i]<>S[x-i+1] then kt:=false; if kt then write('Xau la palindrome') else write('Xau khong la palindrome'); readln end. end.

V D

Bi 2. program Bai2; uses crt; var S:string; i,n,dem:integer; i,n,dem:integer; ch:char; begin clrscr; write('Nhap xau: ');readln(S); for i:=1 to length(S) do s[i]:=upcase(s[i]); for ch:='A' to 'Z' do begin dem:=0; for i:=1 to length(s) do if s[i]=ch then dem:=dem+1;

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

if dem>0 then writeln('Trong xau co ',dem,' chu ',ch); end; end; readln end. end.

V D

Bi 3. program anhem; uses crt; var S:string; i,n:integer; begin clrscr; write('Nhap xau: ');readln(s); while pos('anh',s)<> 0 do begin n:=pos('anh',s); delete(S,n,3); insert('em',s,n); END; END; write('Xau moi: ',s); readln end. end.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi tp chng 4
1. M ng l ki u d li u c c u trc b i v m ng l ki u c c u trc c c p t i s m nh t trong cc ngn ng l p trnh. N c xy d ng t nh ng ki u d li u c theo quy t c khun d ng do ngn ng l p trnh cung c p. N c dng ch nh m t nhm i t ng cng m t tnh ch t no . 2. Chng ta ph i khai bo kch th c m ng b i v cch nh s cc ph n t c a n. 3. real, boolean, integer, longint. 4. Tham chi u n ph n t c a m ng m t chi u c xc nh b i tn m ng cng v i ch s , c vi t trong c p ngo c [..] (V d A[1]). Cn tham chi u n ph n t c a m ng 2 chi u c xc nh b i tn m ng cng v i 2 ch s c phn cch b i d u ph y v vi t trong c p ngo c [..] (A[1,2]). Bi 5. uses crt; var a:array[1..100] of integer; n,i,d:integer; csc:boolean; csc:boolean; begin clrscr; write('Nhap n: ');readln(n); for i:=1 to n do begin repeat write('Nhap phan tu thu ',i,': '); readln(a[i]); if abs(a[i])>1000 then writeln('Nhap so nho hon 1000'); until abs(a[i])<=1000; end; csc:=false; d:=a[2]d:=a[2]-a[1]; for i:=2 to n do a[i+1]if a[i+1]-a[i]=d then csc:=true; if csc then writeln('Day la cap so cong') else write('Day khong la cap so cong'); readln end.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bai 6. program bai6; uses crt; var A:array[1..100] of integer; i,n,dem,u,d:integer; begin clrscr; write('Nhap so luong phan tu: ');readln(n); for i:=1 to n do begin repeat write('Nhap phan tu thu ',i,': '); readln(a[i]); if abs(A[i])>1000 then write('Nhap so <1000 OK'); until abs(A[i])<1000; end; end; dem:=0; for i:=1 to n do begin if a[i] mod 2= 0 then dem:=dem+1 end; end; ',nwriteln('So luong so le: ',n-dem); writeln('So luong so chan: ',dem); for i:=1 to n do if a[i]>1 then begin u:=2; while (u<=sqrt(A[i])) and (A[i] mod u <> 0) do u:=u+1; if u>sqrt(A[i]) then d:=d+1; end; end; write('So luong so nguyen to: ',d);

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

readln end. end.

D V D

Bi 7. program bai7; uses crt; var n, i:word; f, f1,f2:word; begin clrscr; repeat write('Nhap N: ');readln(n); if n<2 then writeln('Nhap N>2 OK!'); until n>=2; f1:=1; f2:=2; for i:=3 to n do begin f:=f1+f2; f1:=f2; f2:=f; end; end; write('So fibonaxi thu ',n,' la ' ,f); readln end. end.

V D

Chng trnh thc hin n Nmax=10001. Bi 8. Chng trnh th c hi n vi c hon i v tr dng th i v i dng th N-i+1, ngha l hon i v tr dng u tin v i dng cu i cng c a m ng hai

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

chi u, dng th hai t trn xu ng v i dng th hai t d i ln, Vi c hon i v tr dng th i v i dng i x ng v i n c th c hi n khi i nh n gi tr t 1 n N, lm cho m i dng c hon i v tr 2 l n. V v y m ng A sau khi hon i khng thay i so v i ban u. Bi 9. program bai9; uses crt; var A:array[1..15,1..15] of integer; N, i, j, max, ind, vsp:integer; begin clrscr; write('Nhap N: ');readln(n); for i:=1 to n do for j:=1 to n do begin write('Nhap A[',i,',',j,']: '); readln(A[i,j]); end; end; for i:=1 to n do begin max:=A[1,i];ind:=1; for j:=2 to n do if A[j,i] > max then begin max:=A[j,i]; ind:=j; end; end; vsp:=A[i,i]; A[i,i]:=max; A[ind,i]:=vsp; end; end; for i:=1 to n do begin writeln; for j:=1 to n do write(A[i,j]:3); end; end; writeln; readln end. end.

V D

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi 10. program bai10; uses crt; var S:string; i,dem,n:integer; begin clrscr; write('Nhap xau: ');readln(S); n:=length(S); dem:=0; for i:=1 to n do if (s[i]>='0') and (s[i]<='9') then inc(dem); write('Co ',dem,' chu so trong xau vua nhap'); readln end. end.

V D

Bai 11. program bai11; uses crt; const max=60; type Hocsinh = record hoten:string[30]; ngaysinh:string[10]; diachi:string[50]; toan, van:real; xeploai:char; end; end; var lop:array[1..max] of hocsinh; N, i:byte; begin clrscr; write('Nhap so luong hoc sinh: ');readln(n);

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

for i:=1 to n do with lop[i] do {Ch cu lnh ny} begin writeln('Nhap so lieu hoc sinh thu ',i,':'); write('Ho va ten: ');readln(hoten); write('Ngay sinh: ');readln(ngaysinh); write('Dia chi : ');readln(diachi); write('Diem toan: ');readln(toan); ');readln(van); write('Diem van : ');readln(van); if toan+van>=18 then xeploai:='A'; if (toan+van>=14) and (toan+van<18) then xeploai:='B'; if (toan+van>=10) and (toan+van<14) then xeploai:='C'; if (toan+van<10) then xeploai:='D'; end; end; clrscr; writeln('Danh sach hoc sinh:'); for i:=1 to n do with lop[i] do writeln(hoten:30,'- xep loai: ',xeploai); writeln(hoten:30,'writeln('Danh sach hoc sinh loai A:'); for i:=1 to n do with lop[i] do if xeploai='A' then writeln(hoten:30); readln end. end.

V D
Nhp vo

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Kt qu

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 5:

hao tc vi tp

Bi tp chng
1. M t s tr ng h p ph i dng t p: lu tr l ng thng tin l n, dng lu di, t thay i nh tn ng i trong m t c quan, h s c a sinh vin, lng cn b ,.... 2. SGK 3. Ph i m t p tr c khi c t p v tr c khi s d ng t p ph i c cu l nh m t p trnh d ch bi t th c hi n m c ch m t p c hay ghi, ng th i t con tr t p vo v tr thch h p 4. Ph i dng l nh ng t p sau hi k t thc ghi d li u vo t p th ng t t vi c ghi d li u ra t p. Khng c cu l nh ng t p th chng trnh s khng th ghi c d li u vo t p.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Chng 6:

hng trnh con v lp trnh c cu trc

Bi Thc Hnh S 6 -----------------***** *****---------------------------------*****----------------Chng trnh thuchanh6; program thuchanh6; uses crt; type str = string[79]; var S1, S2:str; dong:byte; dong:byte; dung:boolean; procedure catdan(s1:str; var s2: str); begin s2:=copy(s1,2,length(s1)s2:=copy(s1,2,length(s1)-1)+S1[1]; end; procedure cangiua(var s:str); var n, i:integer; begin n:=length(s); n:=(80n:=(80-n) div 2; for i:=1 to n do s:=' '+s; end; dong:byte); procedure chuchay(s1:str; dong:byte); var s2:str; dung:boolean; begin clrscr; cangiua(s1); clrscr; dung:=false; while not(dung) do begin gotoxy(1,dong); write(s1); delay(100); catdan(s1,s2); 24 s1:=s2;

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

dung:=keypressed; end; end; begin clrscr; write('Nhap xau : ');readln(s1); write('Nhap write('Nhap dong: ');readln(dong); chuchay(s1,dong); readln end.

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi Thc Hnh S 7 -----------------***** *****---------------------------------*****----------------program ttamgiac; uses crt; eps=1.0econst eps=1.0e-6; type diem=record x, y:real; end; tamgiac=record a, b, c:diem; end; var T:tamgiac; d, cn, v: boolean; n, i, deu, can, vuong:word; f,g:text; function khcach(P, Q: Diem):real; begin khcach:=sqrt((P.x-Q.x)*(p.x-q.x)+(p.y-Q.y)*(p.ykhcach:=sqrt((P.x-Q.x)*(p.x-q.x)+(p.y-Q.y)*(p.y-Q.y)); end; procedure daicanh(var R:tamgiac; var a, b, c:real); begin a:=khcach(R.B, R.C); b:=khcach(R.A, R.C); c:=khcach(R.A, R.B); end; procedure tinhchat(var R: tamgiac; var deu,can,vuong:boolean); var a, b, c:real; begin deu:=false; can:=false; vuong:=false; daicanh(R,a,b,c); if (abs(a-b)<eps) and (abs(a-c)<eps) then (abs(a(abs(athen deu:=true else if (abs(a-b)<eps) or (abs(a-c)<eps) or (abs(b-c)<eps) (abs(a(abs(a(abs(bthen can:=true; (abs(a*a+b*b(abs(a*a+c*cif (abs(a*a+b*b-c*c)<eps) or (abs(a*a+c*c-b*b)<eps) (abs(b*b+c*cor (abs(b*b+c*c-a*a)<eps) then

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

vuong:=true; end; begin deu:=0; can:=0; vuong:=0; assign(f,'tamgiac.dat'); reset(f); readln(f,n); assign(g,'tamgiac.out'); rewrite(g); for i:=1 to n do begin readln(f, T.A.x, T.A.y, T.B.x, T.B.y, T.C.x, T.C.y); tinhchat(T,D,cn,v); if d then deu:=deu+1 else begin if cn then can:=can+1; if v then vuong:=vuong+1; end; end; writeln(g,'co ',deu,' tam giac deu'); ',deu,' writeln(g,'co ',can,' tam giac can'); writeln(g,'co ',vuong,' tam giac vuong'); close(f);close(g); end.

V D
Tp vn bn cha ta cc nh ca cc tam gic file-opentamgiac.datVo file-open-g tamgiac.dat-nhy nt open di, nh di, nhn f2 lu li ri nhp d liu

file-opentamgiac.outVo file-open-g tamgiac.out-nhy nt open ri nhn f2 lu li. li. Nhn f6 chuyn sang ca s chng trnh v chy chng trnh. Chy xong yes, nhn yes, nhn f6 cho n khi xut hin ca s vn bn tamgiac.out xem kt qu. Tp vn bn cha kt qu sau khi thc hin chng trnh

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

Bi tp chng
1. SGK 2. Chng trnh con khng c tham s Procedure ve; Begin Writeln(****************); Writeln(*I love you ok!*); Writeln(****************); End; 3. Chng trnh con cho nhi u hn m t k t qu : Procedure hoandoi(var x, y:integer); Var tg:integer; Begin Tg:=x; X:=y; Y:=tg; End; 4. program bai4; uses crt; var x, y:integer; function ucln(a, b:integer): integer; var r:integer; begin while b>0 do begin r:=a mod b; a:=b; b:=r; end; ucln:=a; end; function bcnn(a, b:integer): integer; begin

Great by: Nguy n Tr ng Hong Email: quanaxiem_lovelytnt@yahoo.com

bcnn:=a*b div ucln(a,b); end; end; begin clrscr; write('Nhap x: ');readln(x); write('Nhap y: ');readln(y); write('Boi chung nho nhat: ',bcnn(x,y)); readln end.

V D

You might also like