pascal 1
Program Cuu_chuong_1;
Var
so :Integer;
Begin
Write('-Bang cuu chuong so may ?: ');
Readln(so);
Writeln;
Writeln;
Writeln(' CHUONG TRINH BANG CUU CHUONG');
Writeln('-------------------------------');
Writeln;
Writeln(so:2,' lan 1 = ',so*1:3);
Writeln(so:2,' lan 2 = ',so*2:3);
Writeln(so:2,' lan 3 = ',so*3:3);
Writeln(so:2,' lan 4 = ',so*4:3);
Writeln(so:2,' lan 5 = ',so*5:3);
Writeln(so:2,' lan 6 = ',so*6:3);
Writeln(so:2,' lan 7 = ',so*7:3);
Writeln(so:2,' lan 8 = ',so*8:3);
Writeln(so:2,' lan 9 = ',so*9:3);
Writeln(so:2,' lan 10 = ',so*10:3);
Readln
End.
Program Cuu_chuong_2;
Var
so,i :Integer;
Begin
Write('-Bang cuu chuong so may ?: ');
Readln(so);
Writeln;
Writeln;
Writeln(' CHUONG TRINH BANG CUU CHUONG');
Writeln('-------------------------------');
Writeln;
For i:=1 To 10 Do
Writeln(so:2,' lan ',i:2,' = ',so*i:3);
Readln
End.
Program Hinh_thang;
Var
a,b,h:Integer;
S:Real;
Begin
Writeln('CHUONG TRINH TINH DIEN TICH HINH THANG');
Write('-Cho biet day ngan = ');
Readln(a);
Write('-Cho biet day dai = ');
Readln(b);
Write('-Cho biet chieu cao = ');
Readln(h);
S := 0.5 * (a + b) * h;
Writeln('+Dien tich hinh thang = ',s:6:2,' met vuong');
Readln
End.
Program Tam_Giac;
Var
a,b,c:Integer;
p,s:Real;
Begin
Writeln('CHUONG TRINH TINH DIEN TICH TAM GIAC');
Write('-Cho biet canh thu nhat = ');
Readln(a);
Write('-Cho biet canh thu hai = ');
Readln(b);
Write('-Cho biet canh thu ba = ');
Readln(c);
p := 0.5 * (a + b + c);
s := sqrt(p*(p-a)*(p-c)*(p-c));
Writeln('+Dien tich hinh tam giac = ',s:6:2,' met vuong');
Readln
End.
Program Luc_hut;
CONST
g=6.672E-8;
Var
m1,m2,d,f:Real;
Begin
Writeln('CHUONG TRINH TINH LUC HUT GIUA 2 VAT');
Write('-Khoi luong m1 (gam) = ');
Readln(m1);
Write('-Khoi luong m2 (gam) = ');
Readln(m2);
Write('-Khoang cac giua 2 vat (Cm) = ');
Readln(d);
f := g * m1 * m2 / sqr(d);
Writeln('+Luc hut giua 2 vat = ',f:6:2);
Readln
End.
Program Tinh_luong;
Var
Ten:String;
nc,pc,tam:Integer;
bl,hs,tt,cl:Real;
Begin
Writeln('CHUONG TRINH TINH LUONG');
Writeln('------------------------');
Write('-Cho biet ho ten : ');
Readln(ten);
Write('-Cho biet bac luong : ');
Readln(bl);
Write('-Cho biet ngay cong : ');
Readln(nc);
Write('-Cho biet he so trach nhiem : ');
Readln(hs);
Write('-Cho biet phu cap khu vuc = ');
Readln(pc);
Write('-Cho biet so tien da tam ung ky 1 = ');
Readln(tam);
tt := ((bl/30 * nc * hs)+pc);
cl := tt - tam;
Writeln;
Writeln('+Ong (Ba) : ',ten:24);
Writeln('+Tien luong trong thang = ',tt:10:2,' dong');
Writeln('+So tien con linh = ',cl:10:2,' dong');
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tam_thuc;
Var
a,b,c,x,p:Integer;
Begin
Writeln('TINH TAM THUC');
Writeln('-------------');
Write('-Nhap a= ');
Readln(a);
Write('-Nhap b= ');
Readln(b);
Write('-Nhap c= ');
Readln(c);
Write('-Nhap x= ');
Readln(x);
p:=((a*(x*x)) + (b*x) + c);
Writeln('*Tri cua tam thuc = ',p);
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_Z;
Var
x,z:Real;
Begin
Writeln('TINH GIA TRI Z QUA SO THUC X');
Writeln('----------------------------');
Write('-Nhap tri x = ');
Readln(x);
z:=ln(x + abs(sin(2 * x)));
Writeln('*Gia tri cua Z = ',z:10:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_the_tich_hinh_cau;
Var
s,v,r:Real;
Begin
Writeln('TINH THE TICH HINH CAU KHI BIET DIEN TICH');
Writeln('-----------------------------------------');
Write('-Cho biet dien tich hinh cau: ');
Readln(s);
r:= Sqrt(s/4*pi);
v:=4/3*pi*r*r*r;
Writeln('+The tich hinh cau la: ',v:10:4,' met khoi');
Readln
End.
Program Tinh_dien_tich;
Var
cv,canh,s:Real;
Begin
Writeln('TINH DIEN TICH LON NHAT CUA HINH CHU NHAT');
Writeln('-----------------------------------------');
Write('-Cho biet chu vi chu nhat : ');
Readln(cv);
canh:=cv / 4;
s:=canh * canh;
Writeln('-Chu vi hinh chu nhat = ',cv:10:2,' met');
Writeln('-Dien tich lon nhat se= ',s:10:2,' met vuong' );
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_do_dai_vec_to;
Var
x,y,z:Integer;
l:Real;
Begin
Writeln('TINH CHIEU DAI VECTO');
Writeln('---------------------');
Writeln;
Write('-Cho biet toa do X : ');
Readln(x);
Write('-Cho biet toa do Y : ');
Readln(y);
Write('-Cho biet toa do Z : ');
Readln(z);
l:= Sqrt(Sqr(x) + Sqr(y) + Sqr(z));
Writeln('+Chieu dai cua vecto = ',l:10:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_Gio_Phut_Giay;
Var
sogiay,gio,phut,giay:Integer;
Begin
Writeln('TINH GIO:PHUT:GIAY');
Writeln('------------------');
Write('-Nhap so giay can tinh: ');
Readln(sogiay);
gio:=sogiay DIV 3600;
sogiay:= sogiay MOD 3600;
phut:=sogiay DIV 60;
giay:=sogiay MOD 60;
Writeln;
Writeln('KET QUA CHUYEN DOI');
Writeln('+Neu nhap vao: ',sogiay,' giay');
Writeln('+Doi thanh: ',gio,' gio, ',phut,' phut, ',giay,' giay');
Readln
End.
Program Phep_nhan_so_hoc;
Var
binhan,nhan:LongInt;
donvi,chuc,tram:Integer;
Begin
Writeln('TRINH BAY PHEP NHAN SO HOC');
Writeln('-------------------------');
Write('-Nhap so bi nhan : ');
Readln(binhan);
Write('-Nhap vao so nhan: ');
Readln(nhan);
donvi:=nhan MOD 10;
chuc:=(nhan DIV 10) MOD 10;
tram:=nhan DIV 100;
Writeln(binhan:15);
Writeln('x':9,nhan:6);
Writeln('----':15);
Writeln(donvi*binhan:15);
Writeln(chuc*binhan:14);
Writeln(tram*binhan:13);
Writeln('-------':15);
Writeln(binhan*nhan:15);
Readln
End.
Program Tinh_sin;
Var
goc:Integer;
rad,x:Real;
Begin
Writeln('TINH SIN(X)');
Writeln('-----------');
Write('-Nhap vao mot goc: ');
Readln(goc);
rad:=(pi * goc) / 180;
x:=sin(rad);
Writeln('+Sin(',goc:2,') = ',x:10:8);
Readln;
End.
Program Ky_tu;
Var
ma:Byte;
Begin
Writeln('TIM KY TU KHI BIET MA ASCII');
Writeln('--------------------------');
Write('-Cho biet ma ASCII: ');
Readln(ma);
Writeln('+Ky tu cua ma ASCII: ',ma:2,' la: ',Chr(ma));
Readln
End.
Program Doi_chu_HOA_ra_chu_thuong;
Var
ch,c:Char;
Begin
Writeln('DOI CHU HOA RA CHU THUONG');
Writeln('-------------------------');
Write('-Nhap mot chu HOA bat ky: ');
Readln(ch);
c:=chr(ord(ch)+32);
Writeln('+Doi ra chu thuong la: ',c);
Readln
End.
Program Doi_chu_thuong_ra_chu_HOA;
Var
ch,c1,c2:Char;
Begin
Writeln('DOI CHU THUONG RA CHU HOA');
Writeln('-------------------------');
Write('-Nhap mot ky tu bat ky: ');
Readln(ch);
c1:=upcase(ch);
c2:=chr(ord(ch)-32);
Writeln('+Cach thu nhat, dung ham Upcase: ',c1);
Writeln('+Cach thu hai,khong dung ham Upcase: ',c2);
Readln
End.
Program Chu_ky_con_lac;
Const
g=918;
Var
l,t:Real;
Begin
Writeln('TINH CHU KY DAO DONG CON LAC DON');
Writeln('-----------------------');
Write('-Cho biet chieu dai con lac: ');
Readln(l);
t:=2*pi*sqrt(l/g);
Writeln('+Chu ky dao dong dieu hoa cua con lac: ',t:10:3);
Readln;
End.
Program Tinh_khoang_cach;
Var
a,b,c,d,x,y:Real;
Begin
Writeln('TINH KHOANG CACH TU 1 DIEM DEN DUONG THANG');
Writeln('------------------------------------------');
Write('-Nhap he so a= ');
Readln(a);
Write('-Nhap he so b= ');
Readln(b);
Write('-Nhap he so c= ');
Readln(c);
Write('-Nhap toa do x= ');
Readln(x);
Write('-Nhap toa do y= ');
Readln(y);
d:=((a*x) + (b*y) + c) / Sqrt(Sqr(a) + Sqr(b));
Writeln('+Khoang cach tu diem I den duong thang la: ',d:10:2);
Readln
End.
Program Doi_cho;
Var
so1,so2:Integer;
Begin
Writeln('DOI CHO 2 SO NGUYEN');
Writeln('-------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
so1:=so1+so2;
so2:=so1-so2;
so1:=so1-so2;
Writeln('SAU KHI CHUYEN CHO');
Writeln('+So thu nhat bay gio la: ',so1);
Writeln('+So thu hai bay gio la : ',so2);
Readln
End.
Program Ma_ASCII;
Var
kytu:Char;
Begin
Writeln('TIM MA ASCII CUA KY TU');
Writeln('----------------------');
Write('-Nhap vao mot ky tu: ');
Readln(kytu);
Writeln('+Ma ASCII cua ky tu: ',kytu,' la: ',Ord(kytu));
Readln
End.
Program Xuat_chuoi;
Var
ch:String;
Begin
Writeln('XUAT 5 LAN CHUOI VUA NHAP');
Writeln('-------------------------');
Write('-Nhap vao mot chuoi bat ky: ');
Readln(ch);
Write(ch,', ',ch,', ',ch,', ',ch,', ',ch);
Readln
End.
Program Luc_hap_dan;
Const
gama=6.673E-8;
Var
m1,m2,f,d:Real;
Begin
Writeln('TINH LUC HAP DAN GIUA 2 VAT');
Writeln('----------------------');
Write('-Khoi luong vat thu nhat: ');
Readln(m1);
Write('-Khoi luong vat thu hai : ');
Readln(m2);
Write('-Khoang cach 2 vat: ');
Readln(d);
f:=gama*m1*m2/sqr(d);
Writeln('+Luc hap dan giua 2 vat= ',f:10:3);
Readln
End.
Program Tach_so;
Var
n:Integer;
x,p:Real;
Begin
Writeln('TACH MOT SO NGUYEN THANH 2 SO');
Writeln('-----------------------------');
Write('-Nhap mot so: ');
Readln(n);
x:=2*n/3;
Write('+Con so: ',n,' tach thanh so: ',x:6:2);
Writeln(' va so: ',(n-x):6:2);
Readln
End.
Program Tong_bac_ba;
Var
k,n:Byte;
s:Longint;
Begin
Writeln('TINH TONG BAC 3 CUA N SO NGUYEN DAU TIEN');
Writeln('----------------------------------------');
Write('-Nhap so N= ');
Readln(n);
S:=0;
For k:=1 To N Do
S:=S+(k*k*k);
Writeln('+Tong bac 3 cua ',n,' so nguyen dau tien = ',s);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tam_giac_can;
Var
cao,i,j:Byte;
Begin
Writeln(' TAM GIAC CAN DAC');
Writeln('Chieu cao gioi han tu 1 den 22');
Writeln('------------------------------');
Write('-Nhap chieu cao: ');
Readln(cao);
For i:=1 To cao Do
Begin
Write(#32:cao-i+1);
For J:=1 To (2*i-1) Do
Write('*');
Writeln;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tong_binh_phuong;
Var
i,n,tong:Integer;
Begin
Writeln('TINH TONG BINH PHUONG CAC SO LE');
Writeln(' Tu 1 den N');
Writeln('-------------------------------');
Write('-Nhap N= ');
Readln(n);
tong:=0;
For i:=1 To N Do
If odd(i) Then
tong:=tong+sqr(i);
Writeln;
Writeln('+Tong binh phuong cac so le cua ',n,' so nguyen= ',tong);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_giai_thua;
Var
n,i:Integer;
gt:LongInt;
Begin
Writeln('TINH N!');
Writeln('-------');
Write('-Nhap N= ');
Readln(n);
gt:=1;
For i:=1 To n Do
gt:=gt*i;
Writeln;
Writeln('+Giai thua cua ',n,' = ',gt);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program In_xen_ke;
Var
dai,rong,i,j:Byte;
Begin
Writeln('IN XEN KE CAC DAU SAO');
Writeln('--------------------');
Write('-Nhap chieu dai: ');
Readln(dai);
Writeln('-Nhap chieu rong: ');
Readln(rong);
For i:=1 To rong Do
Begin
If i Mod 2 = 0 Then
For j:=1 To dai Div 2 Do
Write(' *') {dau trang va dau sao}
Else
For j:=1 To dai Div 2 +dai Mod 2 Do
Write('* '); {dau sao va dau trang}
Writeln;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Phep_chia;
Var
chia,bichia,luu,thuong,du:Integer;
Begin
Writeln('PHEP CHIA CHI LA PHEP TRU');
Writeln('-------------------------');
Write('-Nhap so bi chia: ');
Readln(bichia);
Write('-Nhap so chia: ');
Readln(chia);
luu:=bichia;
thuong:=0;
While bichia >=chia Do
Begin
bichia:=bichia-chia;
thuong:=thuong+1;
End;
du:=bichia;
Writeln;
Writeln('+Neu dem so ',luu,' chia cho so ',chia,' ket qua la: ');
Writeln(' *So thuong = ',thuong:6);
Writeln(' *So du = ',du:6);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Nhap_diem;
Const
Sentinel=-1;
Var
ten:String;
diem,cao,thap,dem:Integer;
Begin
Writeln('XU LY DIEM THI');
Writeln('--------------');
cao:=0;
thap:=10;
dem:=0;
Write('-Ho va ten sinh vien: ');
Readln(ten);
Write('-Nhap diem thi: ');
Readln(diem);
While diem <> Sentinel Do
Begin
If diem > cao Then
cao:=diem;
If diem < thap Then
thap:=diem;
dem:=dem+1;
Write('-Nhap diem thi: ');
Readln(diem)
End;
Writeln;
Writeln('+Sinh vien: ',ten);
Writeln('+Da co ',dem,' diem thi');
Writeln('+Diem cao nhat la: ',cao);
Writeln('+Diem thap nhat la: ',thap);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln;
End.
Program Da_thuc;
Var
n,i:Integer;
x,a,dathuc: Real;
Begin
Writeln('TINH TRI CUA DA THUC Pn');
Writeln('-----------------------');
Write('-Nhap so N= ');
Readln(n);
Write('-Nhap so X= ');
Readln(x);
i:=n;
Write('-Nhap tri so A',i,' =');
Readln(a);
dathuc:=a;
While i <> 0 Do
Begin
i:=i-1;
Write('-Nhap tri so A',i,' =');
Readln(a);
dathuc:=dathuc * x + a
End;
Writeln;
Writeln('+Tri cua da thuc = ',dathuc:12:10);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program cat_chuoi;
Var
chuoi,tam:String;
Begin
Writeln('CAT CHUOI THANH TUNG TU');
Writeln('------------------------');
Write('-Nhap mot chuoi: ');
Readln(chuoi);
While chuoi <> '' Do
Begin
While chuoi[1] = #23 Do
chuoi:=copy(chuoi,2,255);
If pos(#32,chuoi) <> 0 Then
tam:=copy(chuoi,1,pos(#32,chuoi))
Else
tam:=chuoi;
Writeln(tam);
Delete(chuoi,1,length(tam));
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program PTB2;
Var
a,b,c,delta : Integer;
x1,x2:Real;
Begin
Writeln('GIAI PHUONG TRINH BAC 2');
Writeln('Bat buoc he so a <> 0');
Writeln('---------------------');
Repeat
Write('-Nhap he so a= ');
Readln(a);
Until a<>0;
Write('-Nhap he so b= ');
Readln(b);
Write('-Nhap he so c= ');
Readln(c);
delta:=b*b - 4*a*c;
If Delta < 0 Then
Writeln('+Phuong trinh vo nghiem')
Else
If delta = 0 Then
Writeln('+Phuong trinh co 2 nghiem bang nhau X= ',-b/(2*a):6:2)
Else
Begin
Writeln('Phuong trinh co 2 nghiem phan biet');
Writeln('+X1 = ',(-b+sqrt(delta))/(2*a):6:2);
Writeln('+X2 = ',(-b-sqrt(delta))/(2*a):6:2);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program May_tinh_tay;
Var
so1,so2,kq:Real;
toantu,tiep:Char;
thuchien:Boolean;
Begin
Writeln(' MAY TINH TAY');
Writeln('Thuc hien 4 phep tinh so hoc');
Writeln('----------------------------');
Repeat
Write('-Bam so: ');
Readln(so1);
Write('-Phep toan(+,-,*,/): ');
Readln(toantu);
Write('-Bam so: ');
Readln(so2);
thuchien:=True;
Case toantu Of
'+' :kq:=so1+so2;
'-' :kq:=so1-so2;
'*' :kq:=so1*so2;
'/' :If so2 <> 0 Then
kq:=so1/so2
Else
thuchien:=False;
Else thuchien:=False;
End;
If thuchien Then
Writeln('+Ket qua = ',kq:6:2)
Else
Writeln('+Khong lam duoc');
Writeln;
Write('-Thuc hien tiep khong ? (C/K) ');
Readln(tiep);
Until Upcase(tiep) = 'K';
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_so_he_2;
Var
n,so:Integer;
tiep:Char;
Begin
Writeln('DOI SO HE 10 SANG HE 2');
Writeln('----------------------');
Repeat
Write('-Nhap so nguyen he 10: ');
Readln(so);
n:=16384; {Gan n= 2 luy thua 14}
Writeln;
Write('+So he 2 la ');
Repeat
Write(so Div n);
so:=so - n * (so Div n);
n:= n Div 2;
Until n=0;
Writeln;
Write('-Tiep tuc nua khong (C/K) ');
Readln(tiep);
Until Upcase(tiep)='K';
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Uoc_so_chung_Boi_so_chung;
Var
so1,so2:Word;
p:LongInt;
tiep:Char;
Begin
Writeln('TINH UOC SO CHUNG LON NHAT, BOI SO CHUNG NHO NHAT');
Writeln(' Su dung vong lap Repeat... Until');
Writeln('-------------------------------------------------');
Repeat
Writeln;
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
p:=so1 * so2;
Write('+Uoc so chung lon nhat cua ',so1,' va ',so2,' la: ');
Repeat
if so1 > so2 Then
so1:=so1 - so2
Else
so2:=so2 - so1;
Until so1=so2;
Writeln(so1);
Writeln;
Writeln('+Boi so chung nho nhat: ',P Div so1);
Writeln;
Write('-Co tiep tuc nua khong ? (C/K) ');
Readln(tiep);
Until Upcase(tiep)='K';
Writeln;
Writeln(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Dan_so;
Var
i:Byte;
sodan:LongInt;
Begin
Writeln('TINH DAN SO SAU 5 NAM');
Writeln('---------------------');
sodan:=5000000;
Writeln('-So dan hien nay = ',sodan);
Writeln('-Ty le tang dan so hang nam = 1.5%');
Writeln;
Writeln('So dan tang tung nam trong 5 nam toi la:');
For i:=1 To 5 Do
Begin
sodan:=round(sodan * 1.015);
Writeln('-Nam thu ',i,' so dan la: ',sodan,' nguoi');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program To_hop_chp_k_cua_N;
Var
i,k,n:Integer;
c:Real;
Begin
Writeln('TINH TO HOP CHAP k CUA N');
Writeln(' Voi k <= N');
Writeln('------------------------');
Write('-Nhap so N= ');
Readln(n);
Write('-Nhap so phan tu k= ');
Readln(k);
If k > N Then
Writeln('+Vi k lon hon N nen khong tinh duoc')
Else
Begin
c:=1;
For i:=1 To k Do
c:=c*(n-k+i)/i;
Writeln('+To hop chap ',k,' cua ',n,' la: ',c:2:2);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program ga_cho;
Var
x,y,n:Integer;
Begin
n:=1;
Writeln('* CAC LOI GIAI BAI TOAN CO DIEN GA,CHO');
Writeln('----------------------------------');
For x:=1 To 36 Do
For y:=1 To (36-x) Do
If ((x*2)+(y*4) =100) then {and ((x+y) =36) Then}
Begin
Writeln(' * Loi giai thu : ',n:3);
Write('- Ga = ',x:2,' con = ',(x*2):2,' chan ');
Write('- Cho = ',y:2,' con = ',(y*4):2,' chan ');
If x+y<36 Then
Writeln('Ga+Cho= ',x+y:2,' con,khong dung')
Else If x+y=36 Then
Writeln('Ga+Cho= ',x+y:2,' con,loi giai dung');
n:=n+1;
End;
Writeln(' * Tong cong co: ',(n-1):3,' loi giai');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program gap_giay;
Var
day:Real;
solan:Integer;
Begin
Writeln('GAP GIAY CO DO DAY 1 MET');
Writeln('------------------------');
day:=0.1;
solan:=0;
While day < 1000 Do
Begin
day:=day * 2;
solan:=solan+1;
End;
Writeln;
Writeln('+Phai gap toi: ',solan,' lan');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_bong;
Var
thang,tong,cauthu,i:Integer;
tb:Real;
tiep:Char;
Begin
Writeln('THANH TICH CUA DOI BONG');
Writeln('-----------------------');
i:=1;
cauthu:=0;
tong:=0;
tiep:='c';
While Upcase(tiep)='C' Do
Begin
Write('-Cau thu thu ',i,' co so ban thang: ');
Readln(thang);
i:=i+1;
tong:=tong+thang;
cauthu:=cauthu+1;
Write('-Nhap tiep nua khong (c/k) ');
Readln(tiep);
End;
tb:=tong/cauthu;
Writeln;
Writeln('+So cau thu cua Doi= ',cauthu);
Writeln('+So ban thang trung binh cua Doi= ',tb:5:1);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Uoc_so_Boi_so_chung;
Var
a,b:Word;
p:LongInt;
Begin
Writeln('UOC SO CHUNG LON NHAT, BOI SO CHUNG NHO NHAT');
Writeln('--------------------------------------------');
Write('-Nhap so thu nhat a= ');
Readln(a);
Write('-Nhap so thu hai b= ');
Readln(b);
p:=a * b;
Write('+Uoc so chung lon nhat cua ',a,' va ',b,' la: ');
While a <> b Do
Begin
If a > b Then
a:=a - b
Else
b:=b-a
End;
Writeln(a);
Writeln;
Writeln('+Boi so chung nho nhat cua chung la: ',p Div a);
writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Nhap_ky_tu;
Var
kytu:Char;
thoat:Boolean;
Begin
Writeln('NHAP VA IN KY TU, KY SO RA MAN HINH');
Writeln('-----------------------------------');
thoat:=False;
Repeat
Write('-Nhap ky tu (bam ky tu dieu khien) de ket thuc: ');
Readln(kytu);
Case kytu Of
'A'..'Z':Writeln(kytu,' ,chu thuong tuong ung la: ',chr(ord(kytu)+32));
'a'..'z':Writeln(kytu,' ,chu hoa tuong ung la: ',chr(ord(kytu)-32));
'0'..'9':Writeln(kytu);
Else thoat:=True;
End;
Until thoat;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Nhap_diem;
Var
toan,tong,tb:Real;
hs:Byte;
tiep:Char;
Begin
Writeln('NHAP DIEM MON TOAN VA TINH DIEM TRUNG BINH CUA LOP');
Writeln('--------------------------------------------------');
hs:=1;
tong:=0;
tiep:='C';
Repeat
Writeln('-Hoc sinh thu: ',hs);
Write('-Diem mon Toan : ');
Readln(toan);
tong:=tong+toan;
hs:=hs+1;
Write(' -Nhap nua khong (C/K) ');
Readln(tiep);
Until Upcase(tiep)='K';
hs:=hs-1;
tb:=tong/hs;
Writeln('+Tong so diem = ',tong:5:2,' diem');
Writeln('+Tong so ca lop co = ',hs,' hoc sinh');
Writeln('+Diem trung binh cua mon Toan= ',tb:5:2,' diem');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Gui_tiet_kiem;
Var
x,y:Real;
thang:Word;
tiep:Char;
Begin
Writeln('GUI TIEN TIET KIEM');
Writeln('------------------');
Repeat
Write('-So tien hien co: ');
Readln(x);
Write('-So tien muon co: ');
Readln(y);
thang:=0;
Repeat
inc(thang);
x:= x *1.015;
Until x >=y;
Writeln('+Thoi gian can gui: ',thang,' thang');
Writeln;
Write('-Co tiep tuc nua khong (C/K) ');
Readln(tiep);
Until Upcase(tiep)='K';
End.
Program Doan_so;
Var
tren,duoi,giua:Integer;
chon:Word;
Begin
tren:=100;
duoi:=1;
While duoi < tren Do
Begin
Writeln('DOAN SO BAN DANG NGHI TRONG DAU');
Writeln('-------------------------------');
giua:=(tren+duoi) Div 2;
Writeln('-So cua ban Ty: ',giua);
Writeln('-Neu go so 0 se ngung');
Writeln('-Neu ban Ty noi so ',giua,' nho hon thi ban Teo go 1 ');
Write('-Neu ban Ty noi so ',giua,' lon hon thi ban Teo go 2 ');
Readln(chon);
If chon = 0 Then
exit;
If chon = 1 Then
duoi:=giua
Else
tren:=giua
End;
Readln
End.
Program In_Chu_hoa;
Var
kytu:Char;
Begin
Writeln('IN CHU HOA');
Writeln('----------');
Write('-Nhap ky tu: ');
Readln(kytu);
While ('A' <= kytu) And (kytu <='Z') Do
Begin
Writeln(kytu);
Write('-Nhap ky tu: ');
Readln(kytu);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tim_so_nguyen_to;
Var
n,i,j:Integer;
nguyento:Boolean;
Begin
Writeln('TIM CAC SO NGUYEN TO TU 2 DEN N');
Writeln('-------------------------------');
Write('-Nhap so N= ');
Readln(n);
For i:=2 To n Do
Begin
nguyento:=True;
j:=2;
While nguyento And (j <i) Do
Begin
If (i Mod j)=0 Then
nguyento:=False;
j:=j+1;
End;
If nguyento Then
Write(i:4);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Bang_cuu_chuong;
Var
i,j:Integer;
Begin
Writeln(' BANG CUU CHUONG');
Writeln(' ---------------');
For i:=1 To 9 Do
For j:=1 To 5 Do
Write(j:2,' lan ',i:2,' = ',j*i:2,' ');
Writeln;
Writeln(' ---------------------------------------------------');
For i:=1 To 9 Do
For j:=6 To 10 Do
Write(j:2,' lan ',i:2,' = ',j*i:2,' ');
Writeln(' ---------------------------------------------------');
Writeln;
Write(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tram_trau;
Var
dung,nam,gia,co,trau:Integer;
Begin
Writeln('BAI TOAN CO DIEN');
Writeln('Tram trau tram co');
Writeln('Trau dung an 5');
Writeln('Trau nam an 3');
Writeln('Ba trau gia an 1');
Writeln('----------------');
Writeln(' Bai toan nay co cac loi giai sau');
For dung:=0 To 20 Do
For nam:=0 To 33-dung Do
For gia:=0 To (100-(dung+nam)) Do
Begin
co:=5*dung+3*nam+(gia Div 3);
trau:=dung+nam+gia;
If (gia Mod 3 =0) And (trau=100) And ( co=100) Then
Writeln('-Trau dung ',dung,' con, -Trau nam ',nam,' con, -Trau gia ',gia,' con');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tim_cac_so_nguyen;
Var
a,b,c,d:Integer;
khac:Boolean;
Begin
Writeln('TIM CAC SO NGUYEN KHAC NHAU');
Writeln('---------------------------');
For a:=2 To 10 Do
For b:=2 To 10 do
For c:=2 To 10 Do
For d:=2 To 10 Do
Begin
khac:=(a<>b) And (a<>c) And (a<>d)
And (b<>c) And (b<>d) And (c<>d);
If khac And (a*d*d=b*c*c*c) Then
Writeln(a,'*',d,'*',d,' = ',b,'*',c,'*',c,'*',c);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Co_My;
Var
i,j,dai1,dai2,rong1,rong2:Byte;
Begin
Writeln('IN LA CO NUOC MY RA MAN HINH');
Writeln('-----------------------------');
Write('-Nhap chieu rong_1: ');
Readln(rong1);
Write('-Nhap chieu rong_2: ');
Readln(rong2);
Write('-Nhap chieu dai_1: ');
Readln(dai1);
Write('-Nhap chieu dai_2: ');
Readln(dai2);
For i:=1 To rong1 Do
Begin
If odd(i) Then
Begin
For j:=1 To (dai1 Div 2) Do
Write('*',' ');
If odd(dai1) Then
Write(' ','*');
End
Else
Begin
For j:=1 To (dai1 Div 2) Do
Write(' ','*');
If odd(dai1) Then
Write(' ');
End;
For j:=1 to dai2 Do
Write('=');
Writeln;
End;
For i:=1 To rong2 Do
Begin
For j:=1 To dai1+dai2 Do
Write('=');
Writeln;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_he_16;
Var
n,so,chuso:Integer;
tiep:Char;
Begin
Writeln('DOI SO HE 10 SANG HE 16');
Writeln('-----------------------');
Repeat
Write('-Nhap so he 10 = ');
Readln(so);
n:=4096; {16 luy thua 3}
Write('+Ky so he 16= ');
Repeat
chuso:=so Div n;
Case chuso Of
0..9:Write(chuso);
10 .. 15:Write(chr(chuso + 55));
End;
so:=so- n*(so Div n);
n:=n Div 16;
Until n=0;
Writeln;
Write('-Co thuc hien tiep khong ? (C/K) ');
Readln(tiep);
Until Upcase(tiep)='K';
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program So_nguyen_to;
Var
n,i:Integer;
Begin
Writeln('SO NGUYEN TO');
Writeln('------------');
Repeat
Write('-Nhap so N (bam so 0 de ngung)= ');
Readln(n);
Writeln;
i:=1;
If n > 1 Then
Repeat
i:= i +1;
Until (n Mod i = 0);
If i= n Then
Writeln(' +So ',n,' la so nguyen to')
Else
Writeln(' +So ',n, ' khong phai la so nguyen to');
Writeln;
Until n=0;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln;
End.
Program thuaso;
Var
n,i:Integer;
Begin
Writeln('PHAN TICH N THANH TICH CAC THUA SO NGUYEN TO');
Writeln('--------------------------------------------');
Write('-Nhap so N= ');
Readln(n);
Repeat
i:=2;
While (n Mod i <> 0) And (i < n ) Do
i:=i + 1;
Write(i:4);
n:=n Div i;
Until n=1;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Luy_thua;
Var
x,n,tich,luythua:Integer;
Begin
Writeln('TINH TRI CUA X LUY THUA N');
Writeln('-------------------------');
Write('-Nhap vao so X= ');
Readln(x);
Write('-Nhap vao luy thua N= ');
Readln(n);
tich:=1;
luythua:=1;
While luythua <= n Do
Begin
tich:=tich * x;
luythua:=luythua + 1;
End;
Writeln;
Writeln(x,' luy thua ',n,' = ',tich);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Dem_chu;
Var
chuoi:String;
i,dem,dai:Byte;
Begin
Writeln('DEM CHU ''ng'' TRONG CHUOI');
Writeln('----------------------');
Write('-Nhap mot chuoi bat ky: ');
Readln(chuoi);
dem:=0;
dai:=length(chuoi);
For i:=1 To dai Do
If chuoi[i]+chuoi[i+1]='ng' Then
inc(dem);
Writeln;
Writeln('Trong cau: ','" ',chuoi,' "');
Writeln('Co ',dem,' lan xuat hien chu ''ng''');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tam_giac_rong;
Var
cao,i:Byte;
Begin
Writeln('VE TAM GIAC RONG');
Writeln('----------------');
Write('-Nhap chieu cao cua tam giac: ');
Readln(cao);
Writeln('*':cao);
For i:=2 To cao-1 Do
Writeln('*':cao-i+1,'*':2*i-2);
For i:=1 To 2*cao-1 Do
Write('*');
Writeln;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Cuc_dai;
Var
i,n:Byte;
so,solon:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG N SO NGUYEN');
Writeln('---------------------------------');
Write('-Muon nhap bao nhieu so: ');
Readln(n);
i:=1;
Write('-So thu ',i,' = ');
Readln(so);
solon:=so;
For i:=2 To N Do
Begin
Write('-So thu ',i,' = ');
Readln(so);
If solon < so Then
solon:=so;
End;
Writeln;
Writeln('+So lon nhat trong ',n,' so vua nhap la so: ',solon);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tong_nghich_dao;
Var
n,i:Integer;
s:Real;
Begin
Writeln('TINH TONG NGHICH DAO N SO NGUYEN DAU TIEN');
Writeln('-----------------------------------------');
Write('-Nhap so N= ');
Readln(n);
S:=0;
For i:= 1 To N Do
S:=S+(1/i);
Writeln;
Writeln('+Tong nghich dao cua ',n,' so nguyen dau tien= ',S:0:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program uoc_so;
Var
i,n:Integer;
Begin
Writeln('TIM CAC UOC SO CUA SO NGUYEN');
Writeln('----------------------------');
Write('-Nhap mot so nguyen: ');
Readln(n);
Writeln;
Writeln('+Cac uoc so cua so ',n,' la: ');
Writeln;
For i:=1 To N Do
If (n Mod i) = 0 Then
Write(i:6);
Writeln;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Ngay_mai_la_ngay_may;
Var
Nam:1900..2000;
Thang:1..12;
Ngay:1..31;
Begin
Writeln('CHO BIET NGAY HOM NAY SE TINH DUOC NGAY MAI');
Writeln('-------------------------------------------');
Repeat
Write('-Cho biet ngay ( so 0 de ngung): ');
Readln(Ngay);
If Ngay = 0 Then
Exit;
Write('-Cho biet thang: ');
Readln(Thang);
Write('-Cho biet nam: ');
Readln(Nam);
Case Thang Of
1,3,5,7,8,10,12 : If Ngay < 31 Then
Ngay:=Ngay+1
Else
If Thang = 12 Then
Begin
Nam:=Nam+1;
Thang:=1;
End
Else
Begin
Thang:=Thang+1;
Ngay:=1;
End;
4,6,9,11 : If Ngay < 30 Then
Ngay:=Ngay+1
Else
Begin
Thang:=Thang+1;
Ngay:=1;
End;
2: If (Ngay < 28) Or ((Ngay=28) And (Nam Mod 4 = 0)) then
Ngay:=Ngay+1
Else
Begin
Thang:=Thang+1;
Ngay:=1;
End;
End;
Writeln;
Writeln('+Ngay mai la ngay: ',Ngay:2,' / ',Thang:2,' / ',Nam:4);
Writeln;
Until Ngay=0;
End.
Program Doi_So_ra_chu;
TYPE
ChuSo='0'..'9';
Donvi=(Muoi,Tram);
Phamvi= 0..999;
CONST
KS:Array[ChuSo] Of String=(' ','mot ',' hai',' ba',
' bon',' nam',' sau',' bay',' tam',' chin');
DV:Array[DonVi] Of String[6]=(' muoi ',' tram');
Var
n:Phamvi;
sn,s:String;
Dodai:Byte;
Begin
Writeln('DOI SO RA CHU');
Writeln('-------------');
Writeln;
Write('-Nhap mot so tu 0 den 999: ');
Readln(n);
Str(n,sn);
DoDai:=Length(sn);
Case DoDai Of
1: s:=KS[sn[1]];
2: Begin
If Sn[1] = '1' Then
s:='muoi'
Else
s:=KS[sn[1]]+DV[Muoi];
If sn[2] = '5' Then
s:=s+'lam'
Else
s:=s+KS[sn[2]];
End;
3: Begin
s:=KS[sn[1]]+DV[Tram];
Case sn[2] Of
'0' : If sn[3] <> '0' Then
s:=s+'le';
'1' : s:=s+'muoi';
Else
s:=s+KS[sn[2]]+DV[Muoi];
End;
If (sn[3]='5') And (sn[2] <>'0') then
s:=s+'lam'
Else
s:=s+KS[sn[3]];
End;
End;
Writeln(s);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
readln
End.
Program Cac_ham_luong_giac;
CONST
g='|';
ke='--------------------------------------------------';
Ten=' CAC HAM LUONG GIAC';
Tde='|DO | RADIAN | SIN | COSIN | TANG | COTANG |';
Var
Doo:1..89;
Rad,s,c,t,ct:Real;
Begin
Repeat
Write('-Nhap do (tu 1 den 89, so 0 de ngung): ');
Readln(Doo);
If Doo= 0 Then
Exit;
Writeln(Ten);
Writeln(ke);
Writeln(Tde);
Writeln(ke);
Rad:=Doo*Pi/180;
s:=Sin(rad);
c:=Cos(Rad);
t:=s/c;
ct:=c/s;
Writeln(g,Doo:2,#248,g,Rad:8:6,g,s:8:6,g,
c:8:6,g,t:8:5,g,ct:8:5,g);
Writeln(ke);
Writeln;
Until Doo=0;
End.
Program So_ngay;
Uses Crt;
TYPE
Nam=1900..2000;
Thang=1..12;
Ngay=1..31;
Var
Nam1,Nam2:Nam;
Thang1,Thang2:Thang;
Ngay1,Ngay2:Ngay;
n:Real;
kq:Boolean;
(*--------------------*)
FUNCTION KTngay(d:Ngay;m:Thang;y:Nam):Boolean;
Begin
KTngay:=True;
Case m Of
4,6,9,11: If d > 30 Then
KTngay:=False;
2 : If (d > 29) Or ((d =29) And (y Mod 4 <> 0)) Then
KTngay:=True;
End;
End;
(*--------------------*)
FUNCTION Julian(d:Ngay;m:Thang;y:Nam):Real; {Lich Julieng}
Var
Tam:Real;
Begin
Tam:=Int((m-14.0)/12.0);
Julian:=d-32075.0+
Int(1461.0*(y+4800.0+Tam)/4.0+
Int(367.0*(m-2.0-Tam*12.0)/12.0)-
Int(3.0*Int(y+4900.00+Tam)/100.0)/4.0)
End;
(*--------------------*)
BEGIN
{$R+}
Repeat
ClrScr;
Writeln(' *Nhap moc thoi gian dau');
Write('-Ngay: ');
Readln(Ngay1);
Write('-Thang: ');
Readln(Thang1);
Write('-Nam: ');
Readln(Nam1);
Kq:=KTngay(Ngay1,Thang1,Nam1);
If not Kq Then
Begin
Sound(100);
Delay(50);
NoSound;
Writeln('-Ngay khong hop le');
End;
Until Kq;
Repeat
ClrScr;
Writeln(' *Nhap moc thoi gian cuoi');
Write('-Ngay: ');
Readln(Ngay2);
Write('-Thang: ');
Readln(Thang2);
Write('-Nam: ');
Readln(Nam2);
Kq:=KTngay(Ngay2,Thang2,Nam2);
If not Kq Then
Begin
Sound(100);
Delay(50);
NoSound;
Writeln('-Ngay khong hop le');
End;
Until Kq;
n:=Julian(Ngay2,Thang2,Nam2)-Julian(Ngay1,Thang1,Nam1);
Writeln('Ket qua: ',n:8:0,' ngay');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Phuong_trinh_trung_phuong;
Var
n,k:0..4;
y:Array[1..2] Of Real;
a,b,c,delta:Real;
Begin
Writeln('GIAI PHUONG TRINH TRUNG PHUONG');
Writeln('------------------------------');
Repeat
Write('-Nhap he so a: ');
Readln(a);
Until a <> 0;
Write('-Nhap he so b: ');
Readln(b);
Write('-Nhap he so c: ');
Readln(c);
Delta:=b*b-4*a*c;
If Delta < 0 Then
Begin
y[1]:=-1;
y[2]:=-1;
End;
If Delta = 0 Then
Begin
y[1]:=-1;
y[2]:=-b/(2*a);
End;
If Delta > 0 Then
Begin
y[1]:=(-b+sqrt(Delta))/(2*a);
y[2]:=(-b-sqrt(Delta))/(2*a);
End;
n:=0;
Writeln(' KET QUA');
for k:=1 to 2 Do
If y[k] > 0 Then
Begin
Writeln(' +X1= ',Sqrt(y[k]):5:3);
Writeln(' +X2= ',-Sqrt(y[k]):5:3);
Inc(n,2)
End
Else
If y[k] = 0 Then
Begin
Writeln('X = 0');
Inc(n);
End;
If n=0 Then
Writeln('Phuong trinh vo nghiem')
Else
Writeln('Phuong trinh co ',n,' nghiem');
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Thu_trong_tuan;
Var
d:1..31;
m:1..14;
y:1900..2000;
a:Integer;
Begin
Writeln('DOI NGAY RA THU TRONG TUAN');
Writeln(' Lich the ky 20');
Writeln('--------------------------');
Repeat
Write('-Ngay ( so 0 de ngung): ');
Readln(d);
If d = 0 Then
Exit;
Write('-Thang: ');
Readln(m);
Write('-Nam: ');
Readln(y);
If m < 3 Then
Begin
m:=m+12;
Dec(y);
End;
a:=d+2*m+(3*(m+1) Div 5)+y+(y Div 4) + 1;
a:=a Mod 7;
Case a Of
0 :Begin
Write('Ngay ',d:2,' / ',m:2,' / ',y:4);
Writeln(' la ngay Thu Bay');
End;
1 :Begin
Write('Ngay ',d:2,' / ',m:2,' / ',y:4);
Writeln(' la ngay Chu Nhat');
End;
Else
Begin
Write('Ngay ',d:2,' / ',m:2,' / ',y:4);
Writeln(' la ngay ',a);
End;
End;
Until d=0;
End.
Program Am_thanh;
Uses Crt;
CONST
Notdon=8*58;
Notdoi=Notdon Div 2;
TYPE
Notnhac=(c,cf,d,df,e,f,ff,g,gf,a,af,b);
Var
Kyam:Notnhac;
(*----------------------*)
PROCEDURE Bannhac(Kyam:Notnhac;Caodo,Truongdo:Integer);
Var
Tanso:Real;
i:Integer;
Begin
Tanso:=32.625;
For i:=1 To Caodo Do
Tanso:=Tanso * 2;
For i:=1 To Ord(Kyam) Do
Tanso:=Tanso * 1.05946;
If Truongdo <> 0 Then
Begin
Sound(Round(Tanso));
Delay(Truongdo);
NoSound
End
Else
Sound(Round(Tanso))
End;
(*----------------------*)
BEGIN
Bannhac(c,4,Notdon);
Bannhac(f,4,Notdon);
Bannhac(g,4,Notdon);
Bannhac(a,4,Notdon);
Bannhac(a,4,Notdon);
END.
Program So_lon;
Var
so1,so2,solon:Integer;
Begin
Writeln('TIM SO LON TRONG 2 SO');
Writeln(' Su dung ham Ord()');
Writeln('---------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
solon:=Ord(so1 >=so2) *so1 + Ord(so2 > so1) * so2;
Writeln('-So lon la so: ',solon);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Vong_tron;
Var
Radius,s,cv :Real;
Begin
Writeln('TINH CHU VI, DIEN TICH VONG TRON');
Writeln('--------------------------------');
Write('-Cho biet ban kinh : ');
Readln(Radius);
cv:=2*Pi*Radius;
S:=Pi*Radius*Radius;
Writeln;
Writeln('+Chu vi vong tron = ',cv:10:2);
Writeln('+Dien tich vong tron = ',s:10:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_do_Mile_Km;
Const
Km_Mile=1.609344;
Var
m,k:Real;
Begin
Writeln('DOI MILE SANG Km');
Write('-Cho biet so Mile can doi: ');
Readln(m);
k:=m * Km_Mile;
Writeln;
Writeln(m:5:2,' dam Anh doi thanh = ',k:5:2,' Km');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Cac_phep_toan;
Var
a,b,c,d,e,x,y,g,h,i:Integer;
Begin
Writeln('CAC PHEP TOAN');
Writeln('-------------');
Writeln;
a:=124;
b:=12;
Writeln(a:3,' DIV ',b:2,' = ',a DIV b);
Writeln(a:3,' MOD ',b:2,' = ',a MOD b);
c:=12;
d:=22;
Writeln(c:2,' AND ',d:2,' = ',c AND d);
Writeln(c:2,' OR ',d:2,' = ',c OR d);
Writeln(c:2,' XOR ',d:2,' = ',c XOR d);
x:=2;
g:=x Shl 7;
Writeln('g = ',x:2,' Shl 7 = ',g);
x:=256;
h:=x Shr 7;
Writeln('h = ',x:2,' Shr 7 = ',h);
i:=g+h;
Writeln('i = g + h = ',i);
Writeln('Lo(i) = ',Lo(i));
Writeln('Hi(i) = ',Hi(i));
Writeln('Swap(i) = ',Swap(i));
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_gia_tri_hang_hoa;
Var
n:Integer;
a,c,l:Real;
Begin
Writeln('TINH GIA TRI HANG HOA');
Writeln('---------------------');
Writeln;
Write('-Cho biet gia goc tra ngay: ');
Readln(a);
Write('-Cho biet lai suat l%/nam: ');
Readln(l);
Write('-Cho biet so ngay tra cham: ');
Readln(n);
c:= a * (1 + n * l / 36000);
Writeln('+Gia hang hoa tra cham = ',c:10:2,' dong');
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Trung_binh;
Var
a,b,c:Integer;
P,S:Real;
Begin
Writeln('TINH TRUNG BINH CONG,TRUNG BINH NHAN');
Writeln('------------------------------------');
Writeln;
Write('-Nhap so thu nhat: ');
Readln(a);
Write('-Nhap so thu hai : ');
Readln(b);
Write('-Nhap so thu ba : ');
Readln(c);
S:=(a + b + c) / 3;
P:=Exp((1 / 3) * Ln(a * b * c));
Writeln('*Trung binh cong cua 3 so= ',s:6:2);
Writeln('*Trung binh nhan cua 3 so= ',p:6:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_tong;
Var
n,tong:Integer;
Begin
Writeln('TINH TONG CUA N SO NGUYEN');
Writeln('-------------------');
Writeln;
Write('-Nhap so nguyen N: ');
Readln(n);
tong:=(n * (n + 1) DIV 2);
Writeln('*Tong tu 1 den N = ',tong);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Gia_hang_hoa;
Var
f,a,pe,pc,r:Real;
n,y,t:Integer;
Begin
Writeln('TINH GIA HANG HOA');
Writeln('-----------------');
Writeln;
Write('-So tien vay = ');
Readln(a);
Write('-Lai suat vay Ngan hang = ');
Readln(r);
Write('-Thoi gian san xuat= ');
Readln(y);
Write('-So san pham thu duoc = ');
Readln(n);
Write('-Thoi gian luu kho = ');
Readln(t);
Write('-Phi ton luu kho = ');
Readln(f);
pe:=a/n;
pc:=pe * (1 + r * (t + y) / 1200) + f * t;
Writeln('*Gia xuat xuong = ',pe:10:2,' dong');
Writeln('*Gia ban de hoa von la : ',pc:10:2,' dong');
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program tinh_luong;
Var
Ten:String[24];
bl,nc,pc,thang:Integer;
tl,hs:Real;
Begin
Writeln('CHUONG TRINH TINH LUONG');
Writeln('-----------------------');
Writeln;
Write('-Cho biet thang : ');
Readln(thang);
Write('-Cho biet ho ten : ');
Readln(ten);
Write('-Cho biet bac luong : ');
Readln(bl);
Write('-Cho biet ngay cong : ');
Readln(nc);
Write('-Cho biet he so : ');
Readln(hs);
Write('-Cho biet phu cap : ');
Readln(pc);
Writeln;
tl:=((bl/30)*nc*hs+pc);
Writeln('+Tien luong thang : ',thang:2,', cua Ong/Ba : ',ten,' la = ',tl:8:2);
Writeln(' Bam phim <Enter> de ve cua so soan thao');
Readln
End.
Program Chu_so;
Var
n:Integer;
Begin
Writeln('XUAT CAC CHU SO CUA SO NGUYEN DUONG N');
Write('-Cho biet so nguyen: ');
Readln(n);
Writeln('So nguyen: ',n:5,' Co cac chu so sau');
Write(' ', n DIV 10000);
n :=n MOD 10000;
Write(' ', n DIV 1000);
n :=n MOD 1000;
Write(' ', n DIV 100);
n :=n MOD 100;
Write(' ', n DIV 10);
n :=n MOD 10;
Write(' ',n);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Diem_trung_binh;
Var
Ten:String[24];
Van,Toan,Ly,Sinh,NgoaiNgu,Tb:Real;
Begin
Writeln('DIEM TRUNG BINH');
Writeln('-------------');
Write('-Cho biet ho ten: ');
Readln(ten);
Write('-Cho biet diem mon Van: ');
Readln(Van);
Write('-Cho biet diem mon Toan: ');
Readln(Toan);
Write('-Cho biet diem mon Ly: ');
Readln(Ly);
Write('-Cho biet diem mon Sinh vat: ');
Readln(Sinh);
Write('-Cho biet diem mon Ngoai ngu: ');
Readln(NgoaiNgu);
tb:=((Van * 3) + (Toan * 2) + (Ly * 2) + Sinh + NgoaiNgu) / 9;
Writeln('+Hoc sinh: ',ten,' co diem trung binh = ',tb:6:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_do_dai_vec_to;
Var
x,y,z:Integer;
l:Real;
Begin
Writeln('TINH CHIEU DAI VECTO');
Writeln('---------------------');
Writeln;
Write('-Cho biet toa do X : ');
Readln(x);
Write('-Cho biet toa do Y : ');
Readln(y);
Write('-Cho biet toa do Z : ');
Readln(z);
l:= Sqrt(Sqr(x) + Sqr(y) + Sqr(z));
Writeln('+Chieu dai cua vecto = ',l:10:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_a_mu_b;
Var
a,b:Integer;
p:Real;
Begin
Writeln('TINH TRI CUA A MU B');
Writeln('-------------------');
Writeln;
Write('-Nhap so nguyen A: ');
Readln(a);
Write('-Nhap so mu B : ');
Readln(b);
P:=Exp(b * Ln(a));
Writeln('*Tri A mu B = ',p:10:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_tien;
Var
v:Integer;
l,n:Real;
Begin
Writeln('TINH TIEN GUI NGAN HANG');
Writeln('-------------------');
Writeln;
Write('-So tien gui = ');
Readln(v);
Write('-Lai suat = ');
Readln(l);
n:=(v * (1 + (l/100)));
Writeln('*Neu gui: ',v,' dong, lai suat 1 nam= ',l:4:2,' %');
Writeln('*So tien lai trong 1 nam = ',Round(v*l/100),' dong');
Writeln('*Von + Lai trong 1 nam = ',Round(n),' dong');
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program sap_xep;
Var
so1,so2,tam:Integer;
Begin
Writeln('SAP XEP 2 SO NGUYEN');
Writeln('-------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
If so1 > so2 Then
Begin
tam:=so1;
so1:=so2;
so2:=tam;
End;
Writeln;
Writeln('Ban vua nhap cac so sau');
Writeln(so1:10);
Writeln(so2:10);
Readln
End.
Program So_lon;
Var
so1,so2:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG 2 SO NGUYEN');
Writeln('---------------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
If so1 > so2 Then
Writeln('+So thu nhat la so lon nhat')
Else
Writeln('+So thu hai la so lon nhat');
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program So_lon;
Var
so1,so2,so3,solon:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG 3 SO NGUYEN');
Writeln(' Cau truc If du');
Writeln('---------------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
Write('-Nhap so thu ba : ');
Readln(so3);
If so1 < so2 Then
solon:=so2
Else
solon:=so1;
If solon < so3 Then
solon:=so3;
Writeln;
Writeln('+So lon nhat trong 3 so la: ',solon);
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program Cong_giay;
Var
gio,phut,giay,them:Integer;
Begin
Writeln('CONG THEM GIAY VAO GIO HIEN HANH');
Writeln('--------------------------------');
Writeln('Nhap vao gio:phut:giay hien hanh');
Write('-Gio : ');
Readln(gio);
Write('-Phut: ');
Readln(phut);
Write('-Giay: ');
Readln(giay);
Write('-Cho biet so giay muon cong them: ');
Readln(them);
If (giay+them) < 60 Then
giay:=giay+them
Else
Begin
giay:=((giay+them)-60);
phut:=phut+1;
If phut >=60 Then
Begin
phut:=phut-60;
gio:=gio+1;
End;
End;
Writeln;
Writeln('+Sau khi cong them so giay vao, gio moi la:');
Writeln(' ',gio,' : ',phut,' : ',giay);
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program So_chan_le;
Var
so,du:Integer;
Begin
Writeln('SO CHAN HAY SO LE');
Writeln('-----------------');
Write('-Nhap mot so nguyen bat ky: ');
Readln(so);
du:=so Mod 2;
Case du Of
0:Begin
Writeln('-So : ',so);
Writeln('-La so chan');
End;
1:Begin
Writeln('-So : ',so);
Writeln('-La so le');
End;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Phan_loai;
Var
ten:String;
diem:Integer;
Begin
Writeln('XEP LOAI HOC TAP');
Writeln('----------------');
Write('-Cho biet ten: ');
Readln(ten);
Write('-Cho biet diem: ');
Readln(diem);
Case diem Of
0,1,2,3,4: Begin
Writeln('+Hoc sinh: ',ten);
Writeln('+So diem : ',diem);
Writeln('+Xep loai KEM');
End;
5,6: Begin
Writeln('+Hoc sinh: ',ten);
Writeln('+So diem : ',diem);
Writeln('+Xep loai TRUNG BINH');
End;
7,8: Begin
Writeln('+Hoc sinh: ',ten);
Writeln('+So diem : ',diem);
Writeln('+Xep loai KHA');
End;
9: Begin
Writeln('+Hoc sinh: ',ten);
Writeln('+So diem : ',diem);
Writeln('+Xep loai GIOI');
End;
10: Begin
Writeln('+Hoc sinh: ',ten);
Writeln('+So diem : ',diem);
Writeln('+Xep loai XUAT SAC');
End;
Else Writeln('Khong co loai diem nay hoac ban go sai');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program PT_bac_nhat;
Var
a,b:Integer;
x:Real;
Begin
Writeln('GIAI PHUONG TRINH BAC NHAT');
Writeln(' aX + b = 0');
Write('-Nhap he so a= ');
Readln(a);
Write('-Nhap he so b= ');
Readln(b);
If a=0 Then
If b=0 Then
Writeln('+Phuong trinh vo dinh')
Else
Writeln('+Phuong trinh vo nghiem')
Else
Begin
x:=-b/a;
Writeln('+Nghiem cua phuong trinh X= ',x:0:6);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Sap_xep;
Var
so1,so2,so3,tam:Integer;
Begin
Writeln('SAP XEP THU TU 3 SO NGUYEN DUONG');
Writeln('-------------------------------');
Write('-Nhap so thu nhat= ');
Readln(so1);
Write('-Nhap so thu hai = ');
Readln(so2);
Write('-Nhap so thu ba = ');
Readln(so3);
If so1 > so2 Then
Begin
tam:=so1;
so1:=so2;
so2:=tam;
End;
If so2 > so3 Then
Begin
tam:=so2;
so2:=so3;
so3:=tam;
End;
If so1 > so2 Then
Begin
tam:=so1;
so1:=so2;
so2:=tam;
End;
Writeln;
Writeln('KET QUA SAP XEP');
Writeln;
Writeln(' ',so1:5);
Writeln(' ',so2:5);
Writeln(' ',so3:5);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Diem_Trung_binh;
Var
Ten:String[24];
Van,Toan,Ly,tb:Real;
Begin
Writeln('TINH DIEM TRUNG BINH VA XEP HANG');
Writeln('--------------------------------');
Write('-Cho biet ho ten: ');
Readln(Ten);
Write('-Cho biet diem mon Van: ');
Readln(Van);
Write('-Cho biet diem mon Toan: ');
Readln(Toan);
Write('-Cho biet diem mon Ly: ');
Readln(Ly);
Tb:=((Van*2)+(Toan*2)+ly)/5;
If tb < 5 Then
Begin
Writeln('+Hoc sinh: ',Ten);
Writeln('+Diem trung binh = ',Tb:4:1);
Writeln('+Xep hang: Hoc luc kem');
End
Else if Tb < 7 Then
Begin
Writeln('+Hoc sinh: ',Ten);
Writeln('+Diem trung binh = ',Tb:4:1);
Writeln('+Xep hang: Hoc luc trung binh');
End
Else if Tb < 9 Then
Begin
Writeln('+Hoc sinh: ',Ten);
Writeln('+Diem trung binh = ',Tb:4:1);
Writeln('+Xep hang: Hoc luc Kha');
End
Else
Begin
Writeln('+Hoc sinh: ',Ten);
Writeln('+Diem trung binh = ',Tb:4:1);
Writeln('+Xep hang: Hoc luc Gioi');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tam_giac;
Var
a,b,c:Integer;
tamgiac,deu,can:Boolean;
Begin
Writeln('BA CANH CUA TAM GIAC ?');
Writeln('----------------------');
Write('-Nhap so thu nhat= ');
Readln(a);
Write('-Nhap so thu hai = ');
Readln(b);
Write('-Nhap so thu ba = ');
Readln(c);
tamgiac:=False;
deu:=False;
can:=False;
If (a+b>c) And (b+c>a) And (c+a>b) Then
Begin
tamgiac:=True;
If (a=b) And (b=c) Then
deu:=True;
If (a=b) Or (b=c) Or (c=a) Then
can:=True;
End;
Writeln;
Writeln(' 3 so vua nhap la:');
Writeln('+Tam giac: ',tamgiac);
Writeln('+Tam giac deu: ',deu);
Writeln('+Tam giac can: ',can);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Khoi_lap_phuong;
Var
a,b,c,m,n,tam:Integer;
Begin
Writeln('KHOI LAP PHUONG CHUI QUA KHUNG CHU NHAT');
Writeln('---------------------------------------');
Writeln(' *Nhap so lieu cho khoi lap phuong');
Write('-Canh thu nhat: ');
Readln(a);
Write('-Canh thu hai : ');
Readln(b);
Write('-Canh thu ba : ');
Readln(c);
Writeln(' *Nap so lieu cho khung chu nhat');
Write('-Canh thu nhat: ');
Readln(m);
Write('-Canh thu hai : ');
Readln(n);
If (a>b) Then
Begin
tam:=a;
a:=b;
b:=tam;
End;
If (b>c) Then
Begin
tam:=b;
b:=c;
c:=tam;
End;
If (a>b) Then
Begin
tam:=a;
a:=b;
b:=tam;
End;
If (m>n) Then
Begin
tam:=m;
m:=n;
n:=tam;
End;
If (a<m) And (b<n) Then
Writeln('+Khoi lap phuong chui qua duoc khung chu nhat')
Else
Writeln('+Khoi lap phuong khong chui qua duoc khung chu nhat');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Nam_nhuan;
Var
nam:Word;
nhuan:boolean;
Begin
Writeln('NAM NHUAN HAY NAM THUONG');
Writeln('------------------------');
Write('-Nhap vao nam can kiem tra: ');
Readln(nam);
If nam Mod 100 = 0 Then
Nhuan:=(nam Mod 400)=0
Else
Nhuan:=(nam Mod 4)=0;
Write('Nam: ',nam, ' la: ');
If nhuan Then
Writeln('nam nhuan')
Else
Writeln('nam thuong ( khong nhuan)');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Hinh_hoc_so_cap;
Var
a,b,c,h,r:Integer;
s:Real;
chon:Byte;
Begin
Writeln('TINH DIEN TICH HINH HOC SO CAP');
Writeln('------------------------------');
Writeln(' 1-Hinh vuong');
Writeln(' 2-Hinh chu nhat');
Writeln(' 3-Hinh tam gia1c');
Writeln(' 4-Hinh thang');
Writeln(' 5-Hinh tron');
Writeln;
Write('-Ban chon cac so tu 1 den 5 de tinh dien tich hinh tuong ung');
Readln(chon);
Case chon Of
1 :Begin
Write('-Nhap canh hinh vuong: ');
Readln(a);
s:=a*a;
Writeln('+Dien tich hinh vuong = ',s:10:2,' met vuong');
End;
2 :Begin
Write('-Nhap chieu rong : ');
Readln(a);
Write('-Nhap chieu dai : ');
Readln(b);
s:=a*b;
Writeln('+Dien tich hinh chu nhat = ',s:10:2,' met vuong');
End;
3 :Begin
Write('-Nhap canh day : ');
Readln(a);
Write('-Nhap chieu cao : ');
Readln(h);
s:=a*h/2;
Writeln('+Dien tich hinh tam giac = ',s:10:2,' met vuong');
End;
4 :Begin
Write('-Nhap day duoi : ');
Readln(a);
Write('-Nhap day tren : ');
Readln(b);
Write('-Nhap chieu cao: ');
Readln(h);
s:=0.5*(a+b)*h;
Writeln('+Dien tich hinh thang = ',s:10:2,' met vuong');
End;
5 :Begin
Write('-Nhap ban kinh : ');
Readln(r);
s:=r*r*pi;
Writeln('+Dien tich hinh tron = ',s:10:2,' met vuong');
End;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program So_ngay;
Var
m,y,songay:Integer;
nhuan:Boolean;
Begin
Writeln('TINH SO NGAY CUA THANG');
Writeln('----------------------');
Write('-Nhap thang: ');
Readln(m);
Write('-Nhap nam : ');
Readln(y);
Nhuan:=False;
If (y Mod 4) = 0 Then
Begin
Nhuan:=True;
If (y Mod 100 =0) And (y Mod 400 <> 0) Then
Nhuan:=False;
End;
Case m Of
1,3,5,7,8,10,12:songay:=31;
4,6,9,11 :songay:=30;
2 :If nhuan Then
songay:=29
Else
songay:=28;
End;
Writeln;
Writeln('Thang ',m:2,' / ',y:4,' co : ',songay,' ngay');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Huong_dan;
Var
chon:Byte;
Begin
Writeln('HUONG DAN MUA VE MAY BAY');
Writeln('------------------------');
Writeln(' 1-Tp Ho Chi Minh di Ha Noi');
Writeln(' 2-Tp Ho Chi Minh di Da Nang');
Writeln(' 3-Tp Ho Chi Minh di Nha Trang');
Writeln(' 4-Tp Ho Chi Minh di Phu Quoc');
Writeln(' 5-Tp Ho Chi Minh di Con Dao');
Writeln(' 6-Tp Ho Chi Minh di Paris');
Writeln(' 7-Tp Ho Chi Minh di London');
Writeln(' 8-Tp Ho Chi Minh di Moscow');
Writeln(' 9-Tp Ho Chi Minh di Bac Kinh');
Writeln(' 10-Tp Ho Chi Minh di Tokyo');
Write('-Chon tuyen nao, go vao so tuong ung (1 - 10): ');
Readln(chon);
Case chon of
1 :Writeln(' Xin moi den quay ve so 1');
2 :Writeln(' Xin moi den quay ve so 2');
3 :Writeln(' Xin moi den quay ve so 3');
4 :Writeln(' Xin moi den quay ve so 4');
5 :Writeln(' Xin moi den quay ve so 5');
6 :Writeln(' Xin moi den quay ve so 6');
7 :Writeln(' Xin moi den quay ve so 7');
8 :Writeln(' Xin moi den quay ve so 8');
9 :Writeln(' Xin moi den quay ve so 9');
10 :Writeln(' Xin moi den quay ve so 10');
Else Writeln('-Khong co tuyen bay nay');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program KT_phim;
Var
phim:Char;
Begin
Writeln('KIEM TRA BAN PHIM');
Writeln('-----------------');
Write('-Bam mot phim: ');
Readln(phim);
Case phim Of
'A'..'Z','a'..'z' :Writeln('+Ban vua bam mot phim ky tu');
'0'..'9' :Writeln('+Ban vua bam mot phim ky so');
'+','-','*','/' :Writeln('+Ban vua bam mot phim toan tu so hoc');
Else Writeln('+Ban vua bam mot phim dac biet');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program He_phuong_trinh_bac_nhat;
Var
a,b,c,d,p,q,r:Real;
Begin
Writeln('GIAI HE PHUONG TRINH BAC NHAT');
Writeln(' aX + bY = c');
Writeln(' pX + qY = r');
Writeln('-----------------------------');
Write('Nhap a= ');
Readln(a);
Write('Nhap b= ');
Readln(b);
Write('Nhap c= ');
Readln(c);
Write('Nhap p= ');
Readln(p);
Write('Nhap q= ');
Readln(q);
Write('Nhap r= ');
Readln(r);
d:=a*a + b*b + p*p + q*q;
If d=0 Then
If (c*c + r*r = 0) Then
Writeln('+He thoa man voi moi X, Y')
Else
Writeln('+He vo nghiem');
If d <> 0 Then
Begin
d:=a*q - b*q;
If d=0 Then
If sqr(c*q-b*r)+sqr(a*r-p*c) = 0 then
Writeln('+He thoa man voi moi X, Y')
Else
Writeln('+ He vo nghiem');
If d <> 0 Then
Begin
Writeln('X = ',(c*q-b*r)/d:5:3);
Writeln('Y = ',(a*r-p*c)/d:5:3);
End;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Dien_tich_tam_giac;
Var
a,b,c:Integer;
p,s:Real;
Begin
Writeln('DIEN TICH TAM GIAC');
Writeln('------------------');
Write('-Nhap so thu nhat: ');
Readln(a);
Write('-Nhap so thu hai : ');
Readln(b);
Write('-Nhap so thu ba : ');
Readln(c);
If (a+b>c) And (b+c>a) And (c+a>b) Then
Begin
Writeln('+Dung la Tam giac');
p:=0.5*(a+b+c);
s:=Sqrt(p*(p-a)*(p-b)*(p-c));
Writeln('+Dien tich= ',s:10:2);
End
Else
Writeln('+Khong phai la Tam giac');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program So_lon_so_nho;
Var
so1,so2,so3,so4,max,min:Integer;
Begin
Writeln('TIM SO LON NHAT VA SO NHO NHAT');
Writeln('-----------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
Write('-Nhap so thu ba : ');
Readln(so3);
Write('-Nhap so thu tu : ');
Readln(so4);
max:=so1;
min:=so1;
If max < so2 Then
max:=so2
Else
min:=so2;
If max < so3 Then
max:=so3
Else
min:=so3;
If max < so4 Then
max:=so4;
Writeln;
Writeln('+So lon nhat trong 4 so: ',so1,',',so2,',',so3,',',so4,' la: ',max);
Writeln('+Va so nho nhat trong 4 so do la : ',min);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Uoc_so;
Var
so1,so2,tam:Integer;
Begin
Writeln('KIEM TRA UOC SO CUA 2 SO NGUYEN');
Writeln('-------------------------------');
Write('-So thu nhat= ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
If so1 < so2 Then
Begin
tam:=so1;
so1:=so2;
so2:=tam;
End;
If (so1 Mod so2) = 0 Then
Writeln('+So: ',so2:4,' la uoc so cua so: ',so1:4)
Else
Begin
Writeln('+Hai so: ',so1:4,' va so ',so2:4);
Writeln(' Khong phai la uoc so cua nhau');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Thu_trong_tuan;
Var
thu,ngay,thang:Byte;
Nam,luu:Integer;
Begin
Writeln('NGAY THU MAY TRONG TUAN');
Writeln('-----------------------');
Write('-Ngay: ');
Readln(ngay);
Write('-Thang: ');
Readln(thang);
Write('-Nam: ');
Readln(nam);
luu:=nam;
nam:=1900 + (nam Mod 1900);
If thang < 3 Then
Begin
thang:=thang + 12;
nam:=nam - 1;
End;
thu:=ABS(ngay+2*thang+3*(thang+1) Div 5+nam+nam Div 4) Mod 7;
Case thu Of
0 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Chu Nhat');
End;
1 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln('+La ngay Thu Hai');
End;
2 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Thu Ba');
End;
3 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Thu Tu');
End;
4 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Thu Nam');
End;
5 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Thu Sau');
End;
6 : Begin
Writeln('+Ngay:',ngay:3,',thang:',thang:3,',nam:',luu:5);
Writeln(' +La ngay Thu Bay');
End;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program PTB2;
Var
a,b,c:Integer;
Delta,x,x1,x2:Real;
Begin
Writeln('GIAI PHUONG TRINH BAC 2');
Writeln('-----------------------');
Write('-Nhap he so a= ');
Readln(a);
Write('-Nhap he so b= ');
Readln(b);
Write('-Nhap he so c= ');
Readln(c);
Delta:=sqr(b)-4*a*c;
If Delta < 0 Then
Writeln('+Phuong trinh vo nghiem')
Else
If Delta=0 Then
Begin
X:=-b/2*a;
Writeln('+Phuong trinh co 2 nghiem bang nhau X1=X2= ',X:6:2);
End
Else
Begin
X1:=-b-Sqrt(Delta)/2*a;
X2:=-b+Sqrt(Delta)/2*a;
Writeln('+Nghiem thu nhat = ',X1:6:2);
Writeln('+Nghiem thu hai = ',X2:6:2);
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program So_lon;
Var
so1,so2,so3,so4,solon1,solon2,solon:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG 4 SO NGUYEN');
Writeln('Cau truc If...Then...Else');
Writeln('-------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
Write('-Nhap so thu ba : ');
Readln(so3);
Write('-Nhap so thu tu : ');
Readln(so4);
If so1 > so2 Then
solon1:= so1
Else
Solon1:=so2;
If so3 > so4 Then
solon2:=so3
Else
solon2:=so4;
If solon1 > solon2 Then
solon:=solon1
Else
solon:=solon2;
Writeln;
Writeln('+So lon nhat trong 4 so la: ',solon);
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
rogram So_lon;
Var
so1,so2,so3,solon:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG 3 SO NGUYEN');
Writeln(' Cau truc If thieu');
Writeln('---------------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
Write('-Nhap so thu ba : ');
Readln(so3);
If so1 < so2 Then
solon:=so2;
If so2 < so3 Then
solon:=so3;
If so3 < so1 Then
solon:=so1;
Writeln;
Writeln('+So lon nhat trong 3 so la: ',solon);
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program So_lon;
Var
so1,so2:Integer;
Begin
Writeln('TIM SO LON NHAT TRONG 2 SO NGUYEN');
Writeln('---------------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
If so1 > so2 Then
Writeln('+So thu nhat la so lon nhat');
If so2 > so1 Then
Writeln('+So thu hai la so lon nhat');
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program Chu_vi_Dien_tich;
Var
d,r,p,s:Integer;
tiep:Char;
(*------------------*)
PROCEDURE Chuvi(x,y:Integer);
Begin
p:=(x+y)*2;
End;
(*------------------*)
PROCEDURE Dientich(x,y:Integer);
Begin
s:=x * y;
End;
(*------------------*)
BEGIN
Repeat
Writeln('TINH CHU VI, DIEN TICH HINH CHU NHAT');
Writeln(' Su dung thu tuc');
Writeln('------------------------------------');
Write('-Nhap chieu rong: ');
Readln(r);
Write('-Nhap chieu dai : ');
Readln(d);
Chuvi(r,d);
Dientich(r,d);
Writeln;
Writeln('+Chu vi hinh chu nhat= ',p);
Writeln('+Dien tich hinh chu nhat= ',s);
Writeln;
Write(' Co thuc hien tiep khong ? (c/k) ');
Readln(tiep);
Until (tiep='k') Or (tiep='K');
END.
Program Doi_cho;
Var
so1,so2:Integer;
(*-----------------*)
PROCEDURE Doi(Var n,m:Integer);
Var
tam:Integer;
Begin
tam:=n;
n:=m;
m:=tam;
End;
(*-----------------*)
BEGIN
Writeln('DOI CHO 2 SO');
Writeln('Dung thu tuc');
Writeln('------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai: ');
Readln(so2);
Writeln('=================');
Writeln(' Truoc khi doi cho');
Writeln('+So thu nhat = ',so1);
Writeln('+So thu hai = ',so2);
Writeln(' Sau khi doi cho');
Doi(so1,so2);
Writeln('*So thu nhat : ',so1);
Writeln('*So thu hai : ',so2);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Doi_he_so;
Var
Ky_so:String;
(*------------------*)
FUNCTION Doiso(x:String):Integer;
Var
j,tong,nhan,so:Integer;
tam:Char;
Begin
tong:=0;
nhan:=1;
For j:= length(x) Downto 1 Do
Begin
tam:=x[j];
If Ord(tam)= 32 Then
tam:='0';
If tam in['0'..'9','A'..'F'] Then {Toan tu in}
Begin
so:=Ord(tam) - 48;
If so > 9 Then
so:=so-7;
tong:=tong + so*nhan;
End
Else
Begin
Doiso:=0;
Exit;
End;
nhan:=nhan*16
End;
Doiso:=tong;
End;
(*------------------*)
BEGIN
Writeln('DOI SO HE 16 SANG HE 10');
Writeln(' Su dung ham');
Writeln('------------------------');
Repeat
Write('Nhap ky so he 16 (go kk de dung): ');
Readln(ky_so);
Writeln;
Writeln('+Doi sang he 10 la = ',Doiso(ky_so));
Writeln;
Until ky_so='kk';
END.
Program So_nho;
Var
so1,so2,so3:Integer;
(*---------------------*)
FUNCTION nho(x,y:Integer):Integer;
Begin
If x < y Then
nho:=x
Else
nho:=y;
End;
(*---------------------*)
BEGIN
Writeln('SO NHO NHAT TRONG 3 SO');
Writeln(' dung ham ');
Writeln('-----------------------------');
Write('-So thu nhat = ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
Write('-So thu ba = ');
Readln(so3);
Writeln;
Writeln('*So nho nhat la: ',nho(nho(so1,so2),so3));
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Lam_tron;
Var
so:Real;
le:Integer;
(*---------------*)
FUNCTION Tron(so:Real;le:Integer):Real;
Var
i,n:LongInt;
Begin
For i:=1 To le+1 Do
so:=so*10;
n:=Trunc(so);
If (n Mod 10) >= 5 Then
n:=(n Div 10) +1
Else
n:=n Div 10;
so:=n;
For i:=1 To le Do
so:=so/10;
Tron:=so;
End;
(*---------------*)
BEGIN
Writeln('LAM TRON SO THUC');
Writeln(' Su dung ham');
Writeln('----------------');
Write('-Nhap so: ');
Readln(so);
Write('-Can bao nhieu so le: ');
Readln(le);
Writeln;
Writeln(' KET QUA');
Writeln('*So nhap vao = ',so:12:10);
Writeln('*So lam tron = ',Tron(so,le):12:le);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Xo_so;
Uses Crt;
Var
quacau,i:Byte;
ch:Char;
BEGIN
ClrScr;
TextColor(Red);
Writeln(' QUAY XO SO');
TextColor(Magenta);
Writeln(' Su dung ham Random');
TextColor(Yellow);
Writeln(' -------------------');
Writeln;
TextColor(Green);
Write(' Cho so qua cau de quay: ');
Readln(quacau);
Writeln;
TextColor(Cyan);
Write(' Bam phim bat ky de bat dau quay xo so');
Repeat
i:= Random(9);
Until KeyPressed;
Writeln;
TextColor(LightBlue);
Write(' Bam phim <Enter> de ngung quay');
Readln;
ch:=ReadKey;
Writeln;
TextColor(Yellow);
Writeln(' KET QUA TRUNG THUONG LA SO: ');
Writeln;
TextColor(Red);
Write(' ');
For i:=1 To quacau Do
Write(' ',Random(9):3);
Writeln;
Writeln;
TextColor(Magenta);
Write(' Bam phim <Enter> de ket thuc');
Readln
END.
Program Doi_tien;
Var
sotien:LongInt;
(*-----------------*)
PROCEDURE Doi(St:LongInt);
Const
Loai:Array[1..6] Of Integer =(50,20,10,5,2,1);
Var
i,soto:Integer;
Begin
i:=1;
Repeat
soto:=st Div loai[i];
If soto <> 0 Then
Writeln(soto,' to loai ',loai[i],' ngan dong');
st:=st Mod loai[i];
i:=i+1;
Until st=0;
End;
(*-----------------*)
BEGIN
Writeln('DOI TIEN SAO CHO SO TO IT NHAT');
Writeln(' Dung thu tuc');
Writeln('------------------------------');
Repeat
Write('-So tien (ngan) co ( so 0 de ngung) : ');
Readln(Sotien);
Doi(Sotien);
Writeln;
Until sotien=0;
END.
Program In_ten_thang;
Var
n:Byte;
(*-----------------*)
FUNCTION thang(x:Byte):String;
Const
Ten_thang:Array[1..12] Of String=('Gieng','Hai','Ba',
'Tu','Nam','Sau','Bay','Tam','Chin','Muoi','Mot','Chap');
Begin
thang:=' Thang '+Ten_thang[x];
End;
(*-----------------*)
BEGIN
Writeln('DOI TEN THANG TU SO RA CHU');
Writeln(' Su dung ham');
Writeln('--------------------------');
Write('-Thang : ');
Readln(n);
If (n < 1) And (n > 12) Then
Write('Khong hop le')
Else
Write(thang(n));
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Tong_cac_so_chan;
Var
m,n:LongInt;
(*--------------------*)
FUNCTION Tong(x,y:LongInt):LongInt;
Var
i,t:LongInt;
Begin
t:=0;
For i:=x To y Do
If (i Mod 2 = 0) Then
Begin
Write(i,' ');
t:=t+i;
End;
Write(' = ');
tong:=t;
End;
(*--------------------*)
BEGIN
Writeln('TINH TONG CAC SO CHAN TU M DEN N');
Writeln(' Su dung ham');
Writeln('--------------------------------');
Write('-Nhap so dau (M) : ');
Readln(m);
Write('-Nhap so cuoi (N): ');
Readln(n);
Writeln(' *Tong cua cac so chan tu ',m,' den ',n,' la:');
Writeln(Tong(m,n));
Writeln;
Write(' Bam phim <Enter> de ket thuc');
Readln;
END.
Program Kiem_tra_ngay;
TYPE
ngay=1..31;
thang=1..12;
Var
d:ngay;
m:thang;
y:Word;
(*--------------------*)
FUNCTION Nhuan(Nam:Word):Boolean;
Begin
If nam Mod 100 = 0 Then
Nhuan:=(Nam Mod 400)=0
Else
Nhuan:=(Nam Mod 4)=0;
End;
(*--------------------*)
FUNCTION So_ngay(d:Ngay; m:Thang; Y:Word): Boolean;
Var
t1,t2,t3:Boolean;
Begin
t1:=(d=30) And (m=2);
t2:=(d=29) And (m=2) And (Not Nhuan(y));
t3:=(d=31) And (m in [2,4,6,9,11]);
If t1 Or t2 Or t3 Then
so_ngay:=False
Else
so_ngay:=True;
End;
(*--------------------*)
FUNCTION Ket_thuc:Boolean;
Var
ch:Char;
Begin
Write('-Tiep tuc nua khong ? (c/k) ');
Readln(ch);
Ket_thuc:=Upcase(ch)='K';
End;
(*--------------------*)
BEGIN
Writeln('KIEM TRA NGAY HOP LE ?');
Writeln(' Su dung ham');
Writeln('----------------------');
Repeat
Write('-Ngay: ');
Readln(d);
Write('-Thang: ');
Readln(m);
Write('-Nam: ');
Readln(y);
If so_ngay(d,m,y) Then
Writeln('*Ngay ',d:2,' Thang ',m:2,' Nam ',y:4,' la hop le')
Else
Writeln('*Ngay ',d:2,' Thang ',m:2,' Nam ',y:4,' khong hop le')
Until Ket_thuc;
END.
Program Doi_he_so;
Var
n:Integer;
(*------------------*)
FUNCTION Doi(so:Integer):String;
Const
ky_so:Array[0..15] Of Char =('0','1','2','3','4','5',
'6','7','8','9','A','B','C','D','E','F');
Var
tam1:Integer;
tam2:String;
Begin
tam1:=Hi(so);
tam2:=ky_so[tam1 Shr 4] + ky_so[tam1 And $0F];
tam1:=Lo(so);
Doi:=tam2+ky_so[tam1 Shr 4] +Ky_so[tam1 And $0F]
End;
(*------------------*)
BEGIN
Repeat
Writeln('DOI SO HE 10 SANG HE 16');
Writeln(' Su dung ham ');
Writeln('-----------------------');
Writeln('Nhap mot so nguyen tu -32768 den 32767');
Write('neu nhap so 0 se ket thuc ');
Readln(n);
Writeln;
Writeln('+So he 10 la = ',n);
Writeln('+Doi sang he 16 la = ',Doi(n));
Writeln;
Until n=0;
END.
Program Tong_nghich_dao;
Var
n,k :1..30; {Kieu mien con }
s:Real;
(*-------------------*)
FUNCTION So(i:Integer):Integer;
Var
j:1..30;
tam:LongInt;
Begin
tam:=1;
For j:=1 To i Do
tam:=tam * j;
So:=tam;
End;
(*-------------------*)
BEGIN
Writeln('TONG NGHICH DAO CUA N SO NGUYEN');
Writeln(' Su dung ham');
Writeln('-------------------------------');
Write('-Nhap so N = ');
Readln(n);
s:=0;
For k:=1 To n Do
s:=s+1/so(k);
Writeln;
Writeln('+Tong nghich dao cua ',n,' so nguyen la: ',s:10:2);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Dao_so;
Var
n:LongInt;
(*-------------------*)
PROCEDURE Daoso(x:LongInt);
Begin
Write(x Mod 10);
If (x Div 10) <> 0 Then
Daoso(x Div 10)
End;
(*-------------------*)
BEGIN
Writeln('DAO NGUOC MOT SO');
Writeln(' Dung thu tuc');
Writeln('--------------');
Write('-Nhap mot so nguyen: ');
Readln(n);
Writeln;
Writeln('+So nhap vao la = ',n);
Write('+Bay gio la = ');
Daoso(n);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Ve_hinh_chu_nhat;
CONST
Hoathi='*';
Var
r,d,i:Integer;
tiep:Char;
(*---------------*)
PROCEDURE Ve(x,y:Integer);
Var
k:Integer;
Begin
For k:=1 To y Do
Write(Hoathi);
Writeln;
For k:=1 To x-2 Do
Writeln(Hoathi,Hoathi:y-1);
For k:=1 To y Do
Write(Hoathi);
Writeln;
End;
(*---------------*)
BEGIN
Repeat
Writeln('VE HINH CHU NHAT RONG');
Writeln(' Dung thu tuc');
Writeln('---------------------');
Write('-Chieu rong = ');
Readln(r);
Write('-Chieu dai = ');
Readln(d);
Ve(r,d);
Writeln;
Write(' Co tiep tuc khong ? (c/k) ');
Readln(tiep);
Until Upcase(tiep)='K';
END.
Program So_ngau_nhien;
CONST
N=100;
TYPE
Nguyen= Set of 1..N;
Var
a:Nguyen;
So,i,spt:Integer;
Begin
Writeln('TIM 10 S0 NGUYEN NGAU NHIEN KHONG AM');
Writeln(' NHO HON 100, KHONG TRUNG NHAU');
Writeln('------------------------------------');
spt:=0;
a:=[];
Randomize;
Repeat
So:=Random(100);
If Not (So In a) Then
Begin
a:=a+[So];
Spt:=Spt +1;
End;
Until Spt = 10;
Writeln;
Writeln('10 so ngau nhien nho hon 100 la: ');
Writeln;
For i:= 0 To 100 Do
If i In a Then
Write(i,', ');
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Nguyen_am_Phu_am;
TYPE
Kytu=Set of Char;
Var
a,b,Nguyen,Phu:Kytu;
Chuoi:String;
i:Integer;
Ch:Char;
Begin
Writeln('CAC NGUYEN AM, PHU AM TRONG MOT CHUOI');
Writeln('-------------------------------------');
Write('-Nhap mot chuoi ky tu: ');
Readln(Chuoi);
a:=['a','e','i','o','u','A','E','I','O','U'];
b:=['a'..'z','A'..'Z'] - a;
Nguyen:=[];
Phu:=[];
For I:=1 To Length(Chuoi) Do
Begin
If Chuoi[i] In a Then
Nguyen:=Nguyen + [Chuoi[i]];
If Chuoi[i] In b Then
Phu:=Phu +[Chuoi[i]];
End;
Writeln;
Writeln('*Chuoi nay co cac nguyen am sau day:');
Write(' ');
For Ch:='A' To 'z' Do
If Ch In Nguyen Then
Write(Upcase(ch),', ');
Writeln;
Writeln('*Chuoi nay co cac phu am sau day:');
Write(' ');
For Ch:='A' To 'z' Do
If Ch In Phu Then
Write(Upcase(Ch),', ');
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program So_khac_nhau;
CONST
M=100;
TYPE
DaySo=Set of 0..255;
DayNguyen=Array[1..M] Of Integer;
Var
a:DayNguyen;
i,n:Integer;
x:DaySo;
Begin
Writeln('IN CAC SO KHAC NHAU CUA DAY SO');
Writeln('------------------------------');
Repeat
Write('Nhap bao nhieu so: ');
Readln(n);
Until N <= M;
For i:=1 To N Do
Begin
Write('-Phan tu thu: ',i,' = ');
Readln(a[i]);
End;
x:=[];
For i:=1 To N Do
If Not (a[i] In x) Then
Begin
Write(a[i],', ');
x:=x+[a[i]];
End;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Dem_phan_tu;
Var
kytu:'A'..'z';
taphop: Set of 'A'..'z';
n,i,spt:Byte;
Begin
Writeln('DEM SO PHAN TU CUA TAP HOP');
Writeln('--------------------------');
Write('-Nhap bao nhieu chu: ');
Readln(n);
taphop:=[];
For i:=1 To N Do
Begin
Write('-Ky tu thu ',i,' la: ');
Readln(kytu);
taphop:=taphop + [Kytu];
End;
For Kytu:= 'A' To 'z' Do
If Kytu In Taphop Then
Inc(spt);
Write('Tap hop gom co ',spt,' phan tu la: ');
For Kytu:='A' To 'z' Do
If Kytu In Taphop then
Write(Kytu,#32);
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program So_so_hang;
Var
Thuong:Set of 0..9;
Sodu:0..9;
So,Soluu,Sohang:Integer;
Begin
Writeln('SO SO HANG CUA MOT SO NGUYEN');
Writeln('----------------------------');
Write('-Nhap so nguyen bat ky: ');
Readln(So);
Soluu:=So;
Thuong:=[];
Sohang:=0;
Repeat
Sodu:=So Mod 10;
If Not (Sodu In Thuong) Then
Sohang:=Sohang + 1
Else
Begin
Sohang:=Sohang + 1;
Thuong:=Thuong + [Sodu]
End;
So:= So Div 10;
Until So = 0;
Writeln;
Writeln(' *So ',Soluu,' co ',Sohang,' so hang');
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Tim_ky_tu;
Var
Chuoi:String;
Co,Khong:Set of Char;
i:Integer;
Ch:Char;
Begin
Writeln('TIM KY TU KHONG XUAT HIEN TRONG CHUOI');
Writeln('-------------------------------------');
Write('-Nhap mot chuoi ky tu: ');
Readln(Chuoi);
Co:=[];
For I:=1 To Length(Chuoi) Do
Co:=Co+[Upcase(Chuoi[i])];
Khong:=['A'..'Z'] - Co;
Writeln;
Writeln(' Nhung ky tu khong co trong chuoi nay la: ');
Writeln;
For Ch:='A' To 'Z' Do
If Ch In Khong Then
Write(Ch,', ');
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Du_lich;
Uses Crt;
TYPE
Diadiem=Set of 1..5;
Var
ng1,ng2,ng3,Ba,Hai,Mot:DiaDiem;
ch1,ch2,ch3,i:Byte;
(*----------------------------*)
PROCEDURE Den(i:Byte);
Begin
Case i Of
1:Write('Da Lat ');
2:Write('Vung Tau ');
3:Write('Nha Trang ');
4:Write('Hue ');
5:Write('Ha Noi ');
End;
End;
(*----------------------------*)
BEGIN
ClrScr;
Writeln('CHUONG TRINH THAM QUAN');
Writeln('----------------------');
Writeln(' 1-Da Lat');
Writeln(' 2-Vung Tau');
Writeln(' 3-Nha Trang');
Writeln(' 4-Hue');
Writeln(' 5-Ha Noi');
Writeln('Chon noi nao, go cac so tu 1 den 5');
Writeln('1-Nguoi thu nhat chon 3 noi:');
Write(' -Noi thu nhat: ');
Readln(ch1);
Write(' -Noi thu hai: ');
Readln(ch2);
Write(' -Noi thu ba: ');
Readln(ch3);
ng1:=[ch1,ch2,ch3];
Writeln('2-Nguoi thu hai chon 3 noi:');
Write(' -Noi thu nhat: ');
Readln(ch1);
Write(' -Noi thu hai: ');
Readln(ch2);
Write(' -Noi thu ba: ');
Readln(ch3);
ng2:=[ch1,ch2,ch3];
Writeln('3-Nguoi thu ba chon 3 noi:');
Write(' -Noi thu nhat: ');
Readln(ch1);
Write(' -Noi thu hai: ');
Readln(ch2);
Write(' -Noi thu ba: ');
Readln(ch3);
ng3:=[ch1,ch2,ch3];
Ba:=ng1 * ng2 * ng3;
Hai:=(ng1*ng2-ng3) + (ng2*ng3-ng1) + (ng3*ng1-ng2);
Mot:=ng1 + ng2 +ng3;
Writeln;
Writeln('*Cac noi ma ca 3 nguoi deu chon: ');
For i:=1 To 5 Do
If i In Ba Then
Den(i);
Writeln;
Writeln('*Noi chi co 2 nguoi chon: ');
For i:=1 To 5 Do
If i In Hai Then
Den(i);
Writeln;
Writeln('*Noi chi co 1 nguoi chon: ');
For i:=1 To 5 Do
If i In Mot Then
Den(i);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
END.
Program Cac_phep_Toan;
TYPE
KyTu=Set of Char;
Var
a,b,Cong,Nhan,tru1,tru2:KyTu;
p:Array[1..100] Of Char;
m,n,i:Byte;
Begin
Writeln('CAC PHEP TOAN TRONG TAP HOP');
Writeln('---------------------------');
a:=[];
b:=[];
Write('-So phan tu cua tap hop A= ');
Readln(m);
For i:=1 To M Do
Begin
Write(' -Phan tu A[',i,']= ');
Readln(p[i]);
a:=a + [p[i]];
End;
Write('-So phan tu cua tap hop B= ');
Readln(n);
For i:=1 To N Do
Begin
Write(' -Phan tu B[',i,']= ');
Readln(p[i]);
b:=b + [p[i]];
End;
Nhan:=a * b;
Writeln('A * B gom cac phan tu: ');
For i:=0 To 255 Do
If Char(i) In Nhan Then
Write(Char(i),#32);
Writeln;
Cong:=a + b;
Writeln('A + B gom cac phan tu: ');
For i:=0 To 255 Do
If Char(i) In Cong Then
Write(Char(i),#32);
Writeln;
Tru1:=a - b;
Writeln('A - B gom cac phan tu: ');
For i:=0 To 255 Do
If Char(i) In Tru1 Then
Write(Char(i),#32);
Writeln;
Tru2:=b - a;
Writeln('B - A gom cac phan tu: ');
For i:=0 To 255 Do
If Char(i) In Tru2 Then
Write(Char(i),#32);
Writeln;
If A <= B Then
Writeln('-Tap hop A nho hon tap hop B');
If B <= A Then
Writeln('-Tap hop B nho hon tap hop A');
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Bau_cu;
CONST
Max=100;
ucv=5;
tke:Array[1..5] Of Word =(0,0,0,0,0);
TYPE
stt=1..ucv;
phieubau=Set of stt;
Var
Phieu:Array[1..Max] Of Phieubau;
n,n1,i:1..Max;
j:1..ucv;
Ch:Char;
Bau:0..5;
Begin
Writeln('KIEM PHIEU BAU CU CHI DOAN TN');
Writeln('-----------------------------');
Write('-Cho biet so nguoi tham gia bau (1..100): ');
Readln(n);
{Gan tat ca cac tap hop bang rong}
FillChar(Phieu, Sizeof(Phieu), #0);
{Nhap phieu bau cua tat ca cac cu tri}
For i:=1 To N Do
Begin
Write('-Cu tri thu ',i);
For j:=1 To ucv Do
Begin
Write(' +Chon ung cu vien thu ',j,' (C/K) ? ');
Readln(Ch);
Ch:=Upcase(Ch);
If Ch = 'C' Then
Phieu[i]:=Phieu[i] + [j];
End;
End;
{Kiem tra phieu hop le }
n1:=n;
For i:=1 To n Do
Begin
Bau:=0;
For j:=1 To ucv Do
If j In Phieu[i] Then
Inc(Bau);
If Bau <> 3 then
Begin
Phieu[i]:=[];
Dec(n1);
End;
End;
{Kiem phieu}
For i:= 1 To n Do
For j:=1 To ucv Do
If j IN Phieu[i] Then
Inc(Tke[j]);
Writeln;
Writeln(' KET QUA KIEM PHIEU');
Writeln('-So phieu hop le: ',n1,' phieu');
For j:=1 To ucv Do
Writeln('-So phieu chon ung cu vien thu: ',j,' la ',Tke[j]);
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Phep_Cong;
Var
so1,so2,so3,tong :Integer;
Begin
Writeln(' CHUONG TRINH THUC HIEN PHEP CONG SO HOC');
Writeln(' co toi da 4 ky so');
Write('-Nhap so thu nhat = ');
Readln(so1);
Write('-Nhap so thu hai = ');
Readln(so2);
Write('-Nhap so thu ba = ');
Readln(so3);
tong:= so1+so2+so3;
Writeln;
Writeln;
Writeln('-------------------------------');
Writeln;
Writeln(' ',so1:4);
Writeln(' + ',so2:4);
Writeln(' ',so3:4);
Writeln(' -----');
Writeln(' = ',tong:5);
Readln
End.
Program So_nguyen_he_16;
Var
x,y:Byte;
Begin
Write('-Nhap so X (he 16) = ');
Readln(x);
y:= x + ($2 * $A);
Writeln('Bieu thuc Y = X + ($2 * $A) la : ',Y);
Readln
End.
Program Phep_toan_so_hoc;
Begin
Writeln('28 + 12 = ',28+12:6);
Writeln('28 - 12 = ',28-12:6);
Writeln('28 * 12 = ',28*12:6);
Writeln('28 / 12 = ',28/12:6:2);
Writeln('28 DIV 12 = ',28 DIV 12:6);
Writeln('28 MOD 12 = ',28 MOD 12:6);
Readln
End.
Program Phep_toan_tren_BIT;
VAR
x,a:Word;
y,b:Integer;
Begin
a:=50;
b:=50;
Writeln('50 AND 15 -------> ',50 AND 15:6);
Writeln('50 OR 15 -------> ',50 OR 15:6);
Writeln('50 XOR 15 -------> ',50 XOR 15:6);
x:= NOT A;
y:= NOT A;
Writeln('NOT 50 (Kieu Word) -------> ',x:6);
Writeln('NOT 50 (Kieu Integer) ------> ',y:6);
Writeln('50 Shl 4 -------> ',50 Shl 4:6);
Writeln('50 Shr 4 -------> ',50 Shr 4:6);
Writeln('Hi(865) ---------> ',Hi(865):6);
Writeln('Lo(865) ---------> ',Lo(865):6);
Writeln('Swap(865) ---------> ',Swap(865):6);
Readln
End.
Program Cac_ham_so_thuc;
Begin
Writeln('CAC HAM TOAN HOC KIEU SO THUC');
Writeln('-----------------------------');
Writeln('Round(3.141592) --------> ',Round(3.141592));
Writeln('Trunc(3.141592) --------> ',Trunc(3.141592));
Writeln('Frac(3.141592) --------> ',Frac(3.141592));
Writeln('Abs(-5.5) --------> ',Abs(-5.5));
Writeln('Sqr(12) --------> ',Sqr(12));
Writeln('Sqrt(144) --------> ',Sqrt(144));
Writeln('Ln(2) --------> ',Ln(2));
Writeln('Exp(2) --------> ',Exp(2));
Writeln('Sin(45*pi/180) --------> ',Sin(45*pi/180));
Writeln('Cos(45*pi/180) --------> ',Cos(45*pi/180));
Writeln('Arctan(45*pi/180)------> ',Arctan(45*pi/180));
Writeln('Tri cua Pi --------> ',Pi);
Writeln(' Bam phim bat ky de ket thuc');
Readln
End.
Program Chuyen_doi_kieu_tu_dong;
Var
a,b:Integer;
c:Real;
Begin
Writeln('BIEN DOI KIEU TU DONG');
Writeln('---------------------');
Writeln('A,B thuoc kieu Integer');
Writeln('C Thuoc kieu Real');
Writeln;
a:=20;
b:=10;
c:=a+b;
Writeln('Phep cong C = A + B = ',c:12:10);
Writeln;
Writeln('A,B da tu dong doi thanh kieu Real');
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Bien_doi_kieu_bat_buoc;
Var
a,b,c:Integer;
Begin
Writeln('THEM TEN KIEU VAO TRUOC DOI SO ');
Writeln('------------------------------');
b:=1234;
c:=1432;
a:=LongInt(b) * 81 DIV c ;
Writeln('-Tri cua a:=b*81 DIV c la: ',a);
Readln
End.
Program Phep_toan_ky_tu;
Var
a,b:Char;
c:String;
Begin
a:='A';
b:='B';
Writeln('CAC PHEP TOAN TREN KIEU KY TU');
Writeln('-----------------------------');
c:=a+b;
Writeln('-Phep cong ky tu');
Writeln('a + b -------> ',c);
c:=a+' '+b;
Writeln('a+'' ''+b -----> ',c);
Writeln('-Phep toan quan he');
Writeln('A = B ---------> ',a=b);
Writeln('A < B ---------> ',a<b);
Writeln('A <= B --------> ',a<=b);
Writeln('A > B ---------> ',a>b);
Writeln('A >= B --------> ',a>=b);
Writeln('A <> B --------> ',a<>b);
Readln
End.
Program Xuat_so_thuc;
Var
c:Real;
Begin
Writeln('CAC HAM TOAN HOC KIEU SO THUC');
Writeln('-----------------------------');
c:=Round(3.141593);
Writeln('Round(3.141592) --------> ',c:13:11);
c:=trunc(3.141592);
Writeln('Trunc(3.141592) --------> ',c:13:11);
Writeln('Frac(3.141592) --------> ',Frac(3.141592):13:11);
Writeln('Abs(-5.5) --------> ',Abs(-5.5):13:11);
c:=Sqr(12);
Writeln('Sqr(12) --------> ',c:13:9);
c:=Sqrt(144);
Writeln('Sqrt(144) --------> ',c:13:10);
Writeln('Ln(2) --------> ',Ln(2):13:11);
Writeln('Exp(2) --------> ',Exp(2):13:11);
Writeln('Sin(45*pi/180) --------> ',Sin(45*pi/180):13:11);
Writeln('Cos(45*pi/180) --------> ',Cos(45*pi/180):13:11);
Writeln('Arctan(45*pi/180) ------> ',Arctan(45*pi/180):13:11);
Writeln('Tri cua Pi --------> ',Pi:13:11);
Writeln(' Bam phim bat ky de ket thuc');
Readln
End.
Program Cac_ham_toan_hoc;
Begin
Writeln('Pred(5) -----------> ',Pred(5):6);
Writeln('Succ(5) -----------> ',Succ(5):6);
Writeln('Abs(-5) -----------> ',Abs(-5):6);
Writeln('Abs(-5.5) -----------> ',Abs(-5.5):6:2);
Writeln('Sqr(10) -----------> ',Sqr(10):6);
Writeln('Sqrt(16) -----------> ',Sqrt(16):6:2);
Writeln('Odd(3) -----------> ',Odd(3));
Writeln('Odd(4) -----------> ',Odd(4));
Writeln('Ln(2) -----------> ',Ln(2):6:2);
Writeln('Exp(2) -----------> ',Exp(2):6:2);
Writeln('Trunc(3.1415) -----------> ',Trunc(3.1415):6);
Writeln('Round(56.678) -----------> ',Round(56.678):6);
Writeln('Round(56.421) -----------> ',Round(56.421):6);
Writeln('Round(-56.678) -----------> ',Round(-56.678):6);
Writeln('Tri so cua hang Pi --------> ',Pi:10:8);
Writeln('Sin(45*pi/180) -----------> ',Sin(45*pi/180):6:2);
Writeln('Cos(45*pi/180) -----------> ',Cos(45*pi/180):6:2);
Writeln('Arctan(45*pi/180) -----------> ',Arctan(45*pi/180):6:2);
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Phep_toan_quan_he;
Var
x:Boolean;
Begin
x:=5=5;
Writeln('5 = 5 -----> ',x);
x:=3<5;
Writeln('3 < 5 -----> ',x);
x:=3<=5;
Writeln('3 <= 5 -----> ',x);
x:=3>5;
Writeln('3 > 5 -----> ',x);
x:=3>=5;
Writeln('3 >= 5 -----> ',x);
x:=3<>5;
Writeln('3 <> 5 -----> ',x);
Readln
End.
Program Vong_lap_For;
Var
i:Integer;
so:array[1..5] Of Real;
tong:Real;
Begin
Writeln(' TINH TONG CUA 5 SO');
Writeln('Su dung cau lenh lap For ... Do');
Writeln('-------------------------------');
For i:=1 To 5 Do
Begin
Write('-Nhap so thu ',i:2,' = ');
Readln(so[i]);
End;
tong:=0;
For i:=1 To 5 Do
tong:=tong+so[i];
Writeln('+Tong cua 5 so = ',tong:0:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program For_tang;
Var
i:Integer;
Begin
Writeln(' CAU LENH FOR DON');
Writeln('Bien dieu khien tang');
Writeln('--------------------');
For i:=1 To 10 Do
Writeln(i);
Writeln;
Writeln(' Bam phim <enter> de ket thuc');
Readln
End.
Program For_long_nhau;
Var
m,n,i,j:Integer;
S:LongInt;
Begin
Writeln(' CAU TRUA FOR LONG NHAU');
Writeln('Chuong trinh tinh tong tich');
Writeln('---------------------------');
Write('-Mhap so M= ');
Readln(m);
Write('-Nhap so N= ');
Readln(n);
s:=0;
For i:=1 To M Do
For j:=1 To N Do
S:=S+i*j;
Writeln('+Tong tich = ',S);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program For_don;
Var
i:Char;
Begin
Writeln('DUNG BIEN DIEU KHIEN LA KIEU CHAR');
Writeln('---------------------------------');
For i:='A' To 'Z' Do
Writeln('Ky tu ',i,' co so thu tu= ',Ord(i));
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program For_don;
Var
i:Byte;
Begin
Writeln('CAU LENH FOR DON');
Writeln('----------------');
For i:=1 To 5 Do
Writeln('Chao ban');
Writeln('Ban co khoe khong');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Vong_lap_While;
Var
i:Integer;
so:array[1..5] Of Real;
tong:Real;
Begin
Writeln('VONG LAP WHILE . . . DO');
Writeln('-----------------------');
tong:=0;
i:=1;
Write('-Nhap so thu: ',i,' = ');
Readln(so[i]);
While (so[i] <>0 ) and (i < 5) Do
Begin
i:=i+1;
Write('-Nhap so thu: ',i,' = ');
Readln(so[i]);
End;
for i:=1 To 5 Do
tong:=tong+so[i];
Writeln('+Tong cua 5 so vua nhap = ',tong:0:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Trung_binh_cong;
Var
so,tong:Integer;
dem:Byte;
tb:Real;
Begin
Writeln('TINH TRUNG BINH CONG');
Writeln('--------------------');
so:=1;
dem:=0;
tong:=0;
While so <> 0 Do
Begin
Write('-Nhap so nguyen (so 0 de ngung): ');
Readln(so);
If so <> 0 Then
tong:=tong+so;
dem:=dem+1;
End;
tb:=tong/(dem-1);
Writeln;
Writeln('+Trung binh cong cua ',(dem-1),' so vua nhap la: ',tb:6:2);
Writeln;
Writeln(' Bam phim <Enter> de cham dut');
Readln
End.
Program So_ky_so;
Var
n,n1:LongInt;
kyso:Byte;
Begin
Writeln('SO KY SO TRONG MOT SO NGUYEN');
Writeln('----------------------------');
Write('-Nhap mot so nguyen: ');
Readln(n);
n1:=n;
kyso:=0;
Repeat
N := N Div 10;
Inc(kyso);
Until (N = 0);
Writeln;
Writeln('+So ',n1,' co ',kyso,' ky so');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Menu;
Var
chon:Byte;
ketthuc:Boolean;
a,b,h,r:Integer;
s:Real;
Begin
Repeat
ketthuc:=False;
Writeln(' TAO MENU');
Writeln(' --------');
Writeln(' 1-Hinh vuong');
Writeln(' 2-Hinh chu nhat');
Writeln(' 3-Hinh tam giac');
Writeln(' 4-Hinh thang');
Writeln(' 5-Hinh tron');
Writeln(' 6-Ket thuc');
Writeln;
Repeat
Write(' Chon cong viec nao (go tu 1 den 6) : ');
Readln(chon);
Until (chon >=1) And (chon <=6);
Case chon Of
1:Begin
Writeln('TINH DIEN TICH HINH VUONG');
Writeln('-------------------------');
Write('-Nhap canh hinh vuong: ');
Readln(a);
s:=a*a;
Writeln('+Dien tich hinh vuong = ',S:6:2);
End;
2:Begin
Writeln('TINH DIEN TICH HINH CHU NHAT');
Writeln('-------------------------');
Write('-Nhap chieu dai: ');
Readln(a);
Write('-Nhap chieu rong: ');
Readln(b);
s:=a*b;
Writeln('+Dien tich hinh chu nhat = ',S:6:2);
End;
3:Begin
Writeln('TINH DIEN TICH HINH TAM GIAC');
Writeln('-------------------------');
Write('-Nhap canh day: ');
Readln(a);
Write('-Nhap chieu cao: ');
Readln(h);
s:=a*h/2;
Writeln('+Dien tich hinh tam giac = ',S:6:2);
End;
4:Begin
Writeln('TINH DIEN TICH HINH THANG');
Writeln('-------------------------');
Write('-Nhap canh day dai: ');
Readln(a);
Write('-Nhap canh day ngan: ');
Readln(b);
Write('-Nhap chieu cao: ');
Readln(h);
s:=0.5*(a+b)*h;
Writeln('+Dien tich hinh thang = ',S:6:2);
End;
5:Begin
Writeln('TINH DIEN TICH HINH TRON');
Writeln('-------------------------');
Write('-Nhap ban kinh: ');
Readln(r);
s:=r*r*pi;
Writeln('+Dien tich hinh tron = ',S:6:2);
End;
6:Ketthuc:=True;
End;
Until ketthuc;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Readln;
End.
Program Tong_binh_phuong;
Var
i,n,s:Integer;
Begin
Writeln('DUNG CAU TRUC WHILE TINH TONG BINH PHUONG');
Writeln('----------------------------------------');
Write('-Nhap N= ');
Readln(n);
s:=0;
i:=1;
While (i <= n) Do
Begin
s:=s + (i*i);
i:=i +1;
End;
Writeln;
Writeln('+Tong binh phuong cua ',n,' so nguyen dau tien= ',s);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Nhap_thang_ngay_nam;
Var
ngay,thang,nam,ngayMax:Integer;
Begin
Writeln('SU DUNG BAY LOI VA HAM IOResult');
Writeln('---------------');
{$I-}
Repeat
Write('-Nhap nam: ');
Readln(nam);
Until(IOResult = 0) And (Nam >=1900) and (nam <=2000);
Repeat
Write('-Nhap thang: ');
Readln(thang);
Until (IOResult = 0) And (thang >=1) And (thang <=12);
Case thang Of
1,3,5,7,8,10,12 :ngayMax:=31;
4,6,7,9,11 :ngayMax:=30;
Else
If (nam Mod 4 =0 ) Then
ngayMax :=29
Else
ngayMax :=28;
End;
Repeat
Write('-Nhap ngay: ');
Readln(ngay);
Until (IOResult = 0) And (ngay >1) And (ngay <=ngayMax);
{$I+}
Writeln('Ngay ',ngay,',thang ',thang,',nam ',nam);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program So_nguyen_to;
Var
j,k,n:Word;
tiep:Char;
Begin
Writeln('SO N CO PHAI LA SO NGUYEN TO HAY KHONG ?');
Writeln('----------------------------------------');
Repeat
Write('-Nhap so N= ');
Readln(n);
k:=trunc(sqrt(n));
j:=1;
Repeat
j:=j+1;
Until (j > k) Or (n Mod j = 0);
If j > k Then
Writeln('+So ',n,' la so nguyen to')
Else
Writeln('+So ',n,' khong phai la so nguyen to');
Writeln;
Write(' *Thuc hien tiep nua khong (c/k) ');
Readln(tiep);
Until Upcase(tiep)='K';
End.
Program Vong_lap_Repeat;
Var
i:Integer;
so:Array [1..5] Of Real;
tong:Real;
Begin
tong:=0;
i:=0;
Repeat
Write('-Nhap mot so: ');
i:=i+1;
Readln(so[i]);
Until (i=5) Or (so[i]=0);
For i:=1 To i Do
Tong:=tong+so[i];
Writeln;
Writeln('+Tong cua ',i,' so= ',tong:0:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Trung_binh_cong;
Var
mk:Char;
so,tong:Integer;
dem:Byte;
tb:Real;
Begin
mk:=' ';
Write('-Ban go vao mat khau: ');
Readln(mk);
While mk<> 'a' Do
Begin
Write('-Ban go vao mat khau: ');
Readln(mk);
End;
Writeln;
Writeln('TINH TRUNG BINH CONG');
Writeln('--------------------');
so:=1;
dem:=0;
tong:=0;
While so <> 0 Do
Begin
Write('-Nhap so nguyen (so 0 de ngung): ');
Readln(so);
If so <> 0 Then
tong:=tong+so;
dem:=dem+1;
End;
tb:=tong/(dem-1);
Writeln;
Writeln('+Trung binh cong cua ',(dem-1),' so vua nhap la: ',tb:6:2);
Writeln;
Writeln(' Bam phim <Enter> de cham dut');
Readln
End.
Program uscln;
Var
so1,so2,x,y:Integer;
Begin
Writeln('TIM UOC SO CHUNG LON NHAT CUA 2 SO');
Writeln('----------------------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
x:=so1;
y:=so2;
While so1 <> so2 Do
If so1 > so2 Then
so1:=so1-so2
Else
so2:=so2-so1;
Writeln;
Writeln('+Uoc so chung cua 2 so ',x,' va ',y,' la: ',so1);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program For_if;
Var
i:Byte;
Begin
Writeln('DUNG FOR KET HOP VOI IF');
Writeln('Dung tung trang man hinh');
Writeln('Bam <Enter> de xem tiep');
Writeln('-----------------------');
For i:=0 To 255 Do
Begin
Writeln('So:',i:3,' la ky tu ',Chr(i));
If (i+1) Mod 24 = 0 Then
Begin
Write(' Bam phim <Enter> de tiep tuc');
Readln;
End;
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tinh_Tong;
Var
so:array[1..5] Of Real;
tong:Real;
Begin
Writeln(' TINH TONG CUA 5 SO');
Writeln('Khong su dung cau lenh lap For...Do');
Writeln('-----------------------------------');
Write('-Nhap so thu 1 = ');
Readln(so[1]);
Write('-Nhap so thu 2 = ');
Readln(so[2]);
Write('-Nhap so thu 3 = ');
Readln(so[3]);
Write('-Nhap so thu 4 = ');
Readln(so[4]);
Write('-Nhap so thu 5 = ');
Readln(so[5]);
tong:=so[1]+so[2]+so[3]+so[4]+so[5];
Writeln('+Tong cua 5 so = ',tong:0:2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Xuat_gia_tri;
TYPE
Ngay=(ThuHai,ThuBa,ThuTu,ThuNam,ThuSau,ThuBay,ChuNhat);
Var
Thu:Ngay;
Begin
Writeln('KIEU LIET KE LA KIEU DEM DUOC');
Writeln(' Cac gia tri cua kieu liet ke');
Writeln('------------------------------');
Writeln;
For Thu:=ThuHai To ChuNhat Do
Case Thu Of
ThuHai :Writeln('Thu Hai');
ThuBa :Writeln('Thu Ba');
ThuTu :Writeln('Thu Tu');
ThuNam :Writeln('Thu Nam');
ThuSau :Writeln('Thu Sau');
ThuBay :Writeln('Thu Bay');
ChuNhat :Writeln('Chu Nhat');
End;
Writeln;
Writeln;
Write('Bam phim <Enter> de ket thuc ');
Readln
End.
Program Cac_Ham;
TYPE
Ngay=(ThuHai,ThuBa,ThuTu,ThuNam,ThuSau,ThuBay,ChuNhat);
Var
Thu:Ngay;
Begin
Writeln(' CAC HAM CUA KIEU LIET KE ');
Writeln(' Tri dau tien la 0');
Writeln(' -------------------------');
Writeln;
Writeln(' Cac gia tri cua kieu liet ke <Ngay>');
Writeln;
Writeln('ThuHai,ThuBa,ThuTu,ThuNam,ThuSau,ThuBay,ChuNhat');
Write(' ');
For Thu:=ThuHai To ChuNhat Do
Begin
Write(Ord(Thu));
Write(' ');
End;
Writeln;
Thu:=ThuBa;
Writeln;
Write(' ');
Write(Ord(Thu));
Write(' la tri cua Ord(ThuBa)');
writeln;
Write(' ');
Write(Succ(Ord(thu)));
Write(' la tri cua Succ(ThuBa)');
Writeln;
Write(' ');
Write(Pred(Ord(Thu)));
Write(' la tri cua Pred(ThuBa)') ;
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Tinh_luong;
CONST
Ten:Array[0..6] Of String =('Thu Hai','Thu Ba',
'Thu Tu','Thu Nam','Thu Sau','Thu Bay','Chu Nhat');
TYPE
TenNgay=(ThuHai,ThuBa,ThuTu,ThuNam,
ThuSau,ThuBay,ChuNhat);
Var
Ngay:TenNgay;
Luong,Gio,Tien:Real;
HoTen:String;
Begin
Writeln('TINH LUONG TUAN THEO SO GIO LAM VIEC');
Writeln('------------------------------------');
Tien:=0.0;
Write('-Ho va ten: ');
Readln(HoTen);
Write('-Tien luong 1 gio: ');
Readln(Luong);
For Ngay:=ThuHai To ChuNhat Do
Begin
Write('-So gio lam viec cua ngay ',Ten[Ord(Ngay)],' : ');
Readln(Gio);
Case Ngay Of
ChuNhat:Gio:=2*gio;
ThuBay: Gio:=1.5 * gio;
End;
Tien:=Tien + gio * Luong;
End;
Writeln;
Writeln('+Ong (Ba) ',HoTen);
Writeln('+Tien luong trong tuan = ',tien:10:2,' dong');
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Khai_Can;
CONST
Gach= '|';
dong='---------------------------------------------';
Ten=' BANG KHAI CAN';
Tde='| N | CAN BAC 2 | CAN BAC 3 | CAN BAC 4 |';
Var
i:0..9;
n:1..100;
can2,can3,can4:Real;
Begin
Writeln('BANG KHAI CAN BAC 2,BAC 3, BAC 4');
Writeln('Vua khai bao bien, vua dinh nghia kieu');
Writeln('---------------------------------------');
For i:=1 To 9 Do
Begin
Writeln;
Writeln(ten);
Writeln;
Writeln(dong);
Writeln(tde);
Writeln(dong);
For n:=10*i+1 To 10*(i+1) Do
Begin
Can2:=Sqrt(n);
Can3:=Exp(Ln(n)/3);
Can4:=Exp(Ln(n)/4);
Writeln(Gach,n:3,Gach,Can2:11:8,' ',Gach, can3:12:8,
' ',Gach,Can4:12:8,Gach);
End;
Writeln(dong);
Writeln;
Write(' Bam phim <Enter> de xem tiep ');
Readln;
End;
End.
Program Thang_Trong_Nam;
TYPE
TenThang=(Gieng,Hai,Ba,Tu,Nam,Sau,Bay,Tam,
Chin,Muoi,MuoiMot,MuoiHai);
Var
Thang:TenThang;
Begin
Writeln('IN RA TEN THANG BANG TIENG ANH');
Writeln(' Kieu liet ke TenThang');
Writeln('------------------------------');
For Thang:=Gieng To MuoiHai Do
Case Thang Of
Gieng :Writeln('Janury');
Hai :Writeln('February');
Ba :Writeln('March');
Tu :Writeln('April');
Nam :Writeln('May');
Sau :Writeln('June');
Bay :Writeln('July');
Tam :Writeln('August');
Chin :Writeln('September');
Muoi :Writeln('October');
MuoiMot :Writeln('November');
MuoiHai :Writeln('December');
End;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program In_ten_thang;
TYPE
TenThang=(Gieng,Hai,Ba,Tu,Nam,Sau,Bay,Tam,
Chin,Muoi,MuoiMot,MuoiHai);
ThuTuThang= 1..12; {Mien con}
Var
so:ThuTuThang; { Kieu mien con}
(*--------------------------*)
FUNCTION Thang(n:ThuTuThang):TenThang;
Var
i:TenThang; {Kieu liet ke}
Begin
For i:=Gieng To MuoiHai Do
If Ord(i) = (so-1) Then
Thang:=i;
End;
(*--------------------------*)
BEGIN
Writeln('IN TEN CAC THANG RA MAN HINH');
Writeln(' Su dung kieu liet ke va mien con');
Writeln('---------------------------------');
Repeat
Write('-Cho so thu tu cua thang (so 0 de ngung): ');
Read(so);
Case thang(so) Of
Gieng : Writeln(' -La thang Gieng');
Hai : Writeln(' -La thang Hai');
Ba : Writeln(' -La thang Ba');
Tu : Writeln(' -La thang Tu');
Nam : Writeln(' -La thang Nam');
Sau : Writeln(' -La thang Sau');
Bay : Writeln(' -La thang Bay');
Tam : Writeln(' -La thang Tam');
Chin : Writeln(' -La thang Chin');
Muoi : Writeln(' -La thang Muoi');
MuoiMot : Writeln(' -La thang Muoi mot');
MuoiHai : Writeln(' -La thang Muoi hai');
End;
Writeln;
Until so=0;
END.
Program Bieu_thuc;
Var
a,b,c,d,e:Integer;
x:Real;
Begin
Write('-Cho a= ');
Readln(a);
Write('-Cho b= ');
Readln(b);
Write('-Cho c= ');
Readln(c);
Write('-Cho d= ');
Readln(d);
Write('-Cho e= ');
Readln(e);
x:=(a + b) / (c + (d / e));
Writeln('+Ket qua x = ',x:6:2);
Readln
End.
Program Kiem_tra_tuoi;
Var
tuoi:Integer;
Begin
Writeln('KIEM TRA TUOI CUA MOT NGUOI');
Write('-Nhap tuoi: ');
Readln(tuoi);
If (tuoi < 18) Then
Begin
Writeln('+Tuoi cua nguoi nay la : ',tuoi,' tuoi');
Writeln('+Nguoi nay con dang o tuoi vi thanh nien');
Writeln('+Nguoi nay chua duoc di bau cu');
End;
Writeln;
Write('+Bam phim <Enter> de ket thuc');
Readln
End.
Program Ca_cuoc;
Var
Bi_1,Bi_2:(Trang,Den);
i:Integer;
Dat_cuoc:Real;
Begin
Repeat
i:=Random(2);
FillChar(Bi_1,1,i);
i:=Random(2);
FillChar(Bi_2,1,i);
Write('Dat diem ca cuoc (so 0 de ket thuc): ');
Readln(Dat_cuoc);
If Dat_cuoc = 0 Then Halt;
If (Bi_1=Trang) And (Bi_2=Den) Then
Begin
Dat_cuoc:=Dat_cuoc * 0.0;
Writeln('Vien bi 1 mau trang, Vien bi 2 cung la mau trang');
Writeln('Ban bi thua het tat ca');
End
Else If (Bi_1=Trang) And (Bi_2=Den) Then
Begin
Dat_cuoc:=Dat_cuoc * (2/3);
Writeln('Vien bi 1 mau trang, Vien bi 2 mau den');
Writeln('Ban bi thua theo ty le 2:3');
End
Else If (Bi_1=Den) And (Bi_2=Trang) Then
Begin
Dat_cuoc:=Dat_cuoc * 1.0;
Writeln('Vien bi 1 mau den, Vien bi 2 mau trang');
Writeln('Van nay hoa 1:1');
End
Else (* (Bi_1=Den) And (Bi_2=Den) *)
Begin
Dat_cuoc:=Dat_cuoc * 2.0;
Writeln('Vien bi 1 mau den, Vien bi 2 cung mau den');
Writeln('Ban thang gap doi so diem dat cuoc');
End;
Writeln('Ban nhan duoc : ',Dat_cuoc:0:2,' diem');
Writeln;
Writeln;
Until i > 100;
End.
Program Cau_truc_if;
Var
so:Integer;
Begin
Writeln('SU DUNG CAU TRUC IF');
Writeln('-------------------');
Write('-Nhap vao mot so: ');
Readln(so);
If ((so > 0) And (so < 5)) Then
Begin
If so = 1 Then
Writeln('Chao quy Ba');
If so = 2 Then
Writeln('Chao quy Ong');
If so = 3 Then
Writeln('Chao quy Co');
If so = 4 Then
Writeln('Chao quy Cau');
End
Else
Writeln('Chao tat ca moi nguoi');
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program Thoat_chuong_trinh;
Var
n:Integer;
ch:Char;
Begin
Repeat
Write('Bam mot phim, "t" de thoat ');
Readln(ch);
If (ch='t') Or (ch ='T') Then
exit {Hoac Halt}
Else
Begin
Write('-Nhap mot so nguyen N= ');
Readln(n);
Writeln('+Binh phuong cua ',n,' = ',Sqr(n));
Writeln('+Can bac hai cua ',n,' = ',Sqrt(n):0:2);
End;
Write('-Thuc hien tiep khong (c/k) ');
Readln(ch)
Until (ch='k') Or (ch='K');
End.
Program Phep_cong;
{$I A:\VIDU\SOHOC.PAS}
Var
so1,so2:Integer;
tiep:Char;
Begin
Repeat
Writeln('PHEP CONG');
Writeln('---------');
Write('-So thu nhat= ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
Writeln;
Writeln('+Ket qua ',so1,' + ',so2,' = ',Cong(so1,so2));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Phep_nhan;
{$I A:\VIDU\SOHOC.PAS}
Var
so1,so2:Integer;
tiep:Char;
Begin
Repeat
Writeln('PHEP NHAN');
Writeln('---------');
Write('-So thu nhat= ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
Writeln;
Writeln('+Ket qua ',so1,' * ',so2,' = ',Nhan(so1,so2));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Binh_phuong;
{$I A:\VIDU\SOHOC.PAS}
Var
n:Integer;
tiep:Char;
Begin
Repeat
Writeln('BINH PHUONG');
Writeln('---------');
Write('-Nhap so N= ');
Readln(n);
Writeln;
Writeln('+Binh phuong cua ',n,' = ',Binhphuong(n));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Lap_phuong;
{$I A:\VIDU\SOHOC.PAS}
Var
n:Integer;
tiep:Char;
Begin
Repeat
Writeln('LAP PHUONG');
Writeln('---------');
Write('-Nhap so N= ');
Readln(n);
Writeln;
Writeln('+Lap phuong cua ',n,' = ',Lapphuong(n));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Phep_chia;
{$I A:\VIDU\SOHOC.PAS}
Var
so1,so2:Integer;
tiep:Char;
Begin
Repeat
Writeln('PHEP CHIA');
Writeln('---------');
Write('-So thu nhat= ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
Writeln;
Writeln('+Ket qua ',so1,' / ',so2,' = ',Chia(so1,so2));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Phep_tru;
{$I A:\VIDU\SOHOC.PAS}
Var
so1,so2:Integer;
tiep:Char;
Begin
Repeat
Writeln('PHEP TRU');
Writeln('---------');
Write('-So thu nhat= ');
Readln(so1);
Write('-So thu hai = ');
Readln(so2);
Writeln;
Writeln('+Ket qua ',so1,' - ',so2,' = ',Tru(so1,so2));
Writeln;
Write('-Thuc hien tiep ? (c/k) ');
Readln(tiep);
Until ((tiep='k') Or (tiep='K'));
End.
Program Truyen_bang_bien;
Uses Crt;
Var
so1,so2:Integer;
(*-------------------*)
Procedure Truyen(Var x,y:Integer);
Begin
Writeln('Trong thu tuc thi');
x:=x+10;
y:=y+10;
Writeln('-Tham so X=X+10= ',x);
Writeln('-Tham so Y=Y+10= ',y);
End;
BEGIN
ClrScr;
Writeln('TRUYEN THAM SO BANG BIEN');
Writeln('-----------------------');
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
Writeln;
Writeln(' +So thu nhat truyen cho tham so X');
Writeln(' +So thu hai truyen co tham so Y');
Writeln;
Truyen(so1,so2);
Writeln;
Writeln(' Sau khi truyen tham so thi');
Writeln(' +So thu nhat bay gio la: ',so1);
Writeln(' +So thu hai bay gio la : ',so2);
Writeln;
Write(' Bam phim <Enter> de ket thuc');
Readln;
END.
Program Tham_so;
Var
so1,so2:Integer;
(*-------------*)
Procedure Doi_cho(x,y:Integer);
Var
tam:Integer;
Begin
tam:=x;
x:=y;
y:=tam;
Writeln('+So thu nhat = ',x);
Writeln('+So thu hai = ',y);
Writeln;
End;
BEGIN
Writeln('THAM SO HINH THUC VA THAM SO THUC');
Writeln('---------------------------------');
Write('-Nhap so thu nhat = ');
Readln(so1);
Write('-Nhap so thu hai = ');
Readln(so2);
Writeln;
Writeln(' SAU KHI DOI CHO');
Writeln;
Doi_cho(so1,so2);
Writeln;
Write(' Bam phim <Enter> de ket thuc');
Readln
END.
Program Lenh_goi_thutuc_va_ham;
Uses Crt;
Var
n:Integer;
Function GiaiThua(x:Integer):LongInt;
Var
i:Integer;
gt:LongInt;
Begin
gt:=1;
For i:=1 To x Do
gt:=gt*i;
Writeln('+Giai thua cua ',x,' = ',gt);
End;
BEGIN
ClrScr;
Writeln('LENH GOI THU TUC VA HAM');
Writeln('-----------------------');
Write('-Nhap so nguyen N= ');
Readln(n);
Writeln('+Binh phuong cua ',n,' = ',Sqr(n));;
Writeln('+Can bac hai cua ',n,' = ',Sqrt(n):0:2);
GiaiThua(n);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln;
END.
Program Xuat_nhap;
Var
a,b:Set of 'A'..'Z';
i,n:Integer;
Ch:Char;
Begin
Writeln('CACH THUC NHAP XUAT DU LIEU KIEU TAP HOP');
Writeln('----------------------------------------');
a:=[];
Write('-Nhap so N: ');
Readln(n);
For i:=1 To N Do
Begin
Write('-Nhap ky tu thu: ',i:2,' = ');
Readln(Ch);
Ch:=Upcase(Ch);
a:=a+[Ch];
End;
Writeln;
Write(n,' Chu hoa sap xep theo thu tu la : ');
Writeln;
For Ch:='A' To 'Z' Do
If Ch In a Then
Write(Ch,', ');
Writeln;
Writeln;
Write(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Doi_thap_phan_ra_nhi_phan;
Var
He10,N,Y:Word;
He2,Tam:String;
Begin
Writeln('DOI SO TU HE THAP PHAN SANG HE NHI PHAN');
Writeln(' -----------------');
Writeln;
Write('-Nhap so nguyen he thap phan: ');
Readln(He10);
N:=He10;
He2:=' ';
Repeat
Y:=He10 Mod 2;
Str(Y, Tam);
He2:=Tam + He2;
He10:= He10 Div 2;
Until He10 = 0;
Writeln;
Writeln('+So he 10 la : ',N);
Writeln('+Doi sang he 2 la: ',He2);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tach_chuoi;
Var
St:String;
Pos,Num:Byte;
Begin
Writeln('TACH CHUOI CON TU CHUOI ME');
Writeln(' Ham Copy');
Writeln(' ---------------');
Write('-Nhap chuoi: ');
Readln(St);
Write('-Tach tu vi tri: ');
Readln(Pos);
Write('-Bao nhieu ky tu: ');
Readln(Num);
Writeln;
Writeln('+Chuoi con la: ',Copy(St,Pos,Num));
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Chuoi_Doi_Xung;
Var
St:String;
i,l:Byte;
Begin
Writeln('CHUOI DOI XUNG');
Writeln(' --------');
Write('-Nhap chuoi: ');
Readln(St);
l:=Length(St);
i:=1;
While (i < l Div 2) And (St[i] = St[l-i+1]) Do
Begin
i:=i+1;
If i < (l Div 2) Then
Writeln('+Chuoi nay doi xung')
End;
While (i < l Div 2) And (St[i] <> St[l-i+1]) Do
Begin
i:=i+1;
If i < (l Div 2) Then
Writeln('+Chuoi nay khong doi xung')
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_So_Ra_Chu;
Var
Tiep:Char;
Chuoitk,Chuoikq:String;
So:0..999;
Tram,Chuc,Donvi:0..9;
Begin
Tiep:='C';
While UpCase(Tiep)='C' Do
Begin
{$R+}
Chuoitk:='MOT HAI BA BON NAM SAU BAY TAM CHIN';
Write('-Nhap so can doi: ');
Readln(so);
If So = 0 Then
Writeln('So khong')
Else
Begin
Tram:=So Div 100;
Chuc:=(So-Tram * 100) Div 10;
Donvi:= So Mod 10;
Chuoikq:=' ';
If (Donvi > 0) And (Donvi <> 5) Then
Chuoikq :=Chuoikq + Copy(Chuoitk,4* Donvi -3,4);
If (Donvi = 5) And (Chuc = 0) Then
Chuoikq :=Chuoikq + ' NAM';
If (Donvi = 5) And (Chuc > 0) Then
Chuoikq := Copy(Chuoitk,4 * Chuc-3,4)+' LAM';
If (Donvi = 5) And (Chuc = 1) Then
Chuoikq := ' LAM';
If Chuc = 1 Then
Chuoikq:='MUOI'+chuoikq;
If (Chuc > 1) And (Donvi = 0) Then
Chuoikq:=Copy(Chuoitk,4 * Chuc-3,4)+' MUOI ';
If (Chuc > 1) And (Donvi = 1) Then
Chuoikq:=Copy(Chuoitk,4 * Chuc-3,4)+' MUOI '+Chuoikq;
If (Chuc > 1) And (Donvi > 1) And (Donvi <>5) Then
Chuoikq:=Copy(Chuoitk,4 * Chuc-3,4)+' MUOI '+Chuoikq;
If (Tram > 0) And (Chuc=0) And (Donvi=0) Then
Chuoikq:=Copy(Chuoitk,4*Tram-3,4)+' TRAM ';
If (Tram > 0) And (Chuc = 0) And (Donvi > 0) Then
Chuoikq := Copy(Chuoitk,4*Tram-3,4)+' TRAM LINH '+ Copy(Chuoitk,4*Donvi-3,4);
If (Tram > 0) And (Chuc = 1) And (Donvi = 0) Then
Chuoikq := Copy(Chuoitk,4*Tram-3,4)+ 'TRAM MUOI';
If (Tram > 0) And (Chuc >= 2) And (Donvi = 0) Then
Chuoikq := Copy(Chuoitk,4*Tram-3,4)+' TRAM '+ Copy(Chuoitk,4*Chuc -3,4) +' MUOI';
If (Tram > 0) And (Chuc <> 0) And (Donvi > 0) Then
Chuoikq := Copy(Chuoitk,4*Tram-3,4)+' TRAM '+ Copy(Chuoitk,4*Chuc -3,4) +' MUOI '+
Copy(Chuoitk,4*Donvi-3,4);
If (Tram > 0) And (Chuc <> 0) And (Donvi = 5) Then
Chuoikq := Copy(Chuoitk,4*Tram-3,4)+' TRAM '+ Copy(Chuoitk,4*Chuc -3,4) +' MUOI LAM';
Write('-Viet bang chu la: ',Chuoikq);
End;
Writeln;
Write('+Tiep tuc nua khong (C/K) ');
Readln(Tiep);
End;
End.
Program Tim_chuoi;
Var
St1,St2:String;
i,sl:Integer;
Begin
Writeln('TIM CHUOI HAI XUAT HIEN TRONG CHUOI MOT');
Writeln(' --------------');
Writeln;
Write('-Chuoi thu nhat: ');
Readln(St1);
Write('-Chuoi thu hai : ');
Readln(St2);
sl:=0;
For i:=1 To Length(St1) Do
If St2 = Copy(St1,i,Length(St2)) Then
sl:=sl+1;
Writeln;
Writeln('+Chuoi thu 2 xuat hien: ',sl:2,' lan trong chuoi 1');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Kiem_tra_so;
Label tt;
Var
St:String;
So:Real;
Dung:Integer;
tiep:Char;
Begin
Repeat
Writeln('KIEM TRA SO NHAP VAO');
Writeln(' -----------');
tt:Write('-Nhap mot so: ');
Readln(St);
Val(St,So,Dung);
If Dung = 0 Then
Writeln(' +Ban da nhap mot so: ',So:8:2)
Else
Writeln(' +Khong phai so, xin nhap lai:');
Until Dung = 0;
Writeln;
Write('-Co tiep tuc khong (C/K) ');
Readln(Tiep);
If UpCase(Tiep)='C' Then
Goto tt;
End.
Program So_La_Ma;
Var
So,So1,i:Integer;
St:String;
Begin
Writeln('DOI SO THAP PHAN SANG SO LA MA');
Writeln(' ------------');
Writeln;
Write('-Nhap so nguyen: ');
Readln(So);
So1:=So;
St:=' ';
For i:=1 To (so Div 1000) Do
St:=St+'M';
So:=So Mod 1000;
If So >= 900 Then
Begin
St:=St+'CM';
So:=So-900;
End
Else
If So >=500 Then
Begin
St:=St+'I';
So:=So-500;
End
Else
If So >=400 Then
Begin
St:=St+'CD';
So:=So-400;
End;
For i:=1 To (so Div 100) Do
St:=St+'C';
So:=So Mod 100;
If So >= 90 Then
Begin
St:=St+'XC';
So:=So-90;
End
Else
If So >=50 Then
Begin
St:=St+'L';
So:=So-50;
End
Else
If So >=40 Then
Begin
St:=St+'XL';
So:=So-40;
End;
For i:=1 To (so Div 10) Do
St:=St+'X';
So:=So Mod 10;
If So >= 9 Then
Begin
St:=St+'IX';
So:=So-9;
End
Else
If So >=5 Then
Begin
St:=St+'V';
So:=So-5;
End
Else
If So >=4 Then
Begin
St:=St+'IV';
So:=So-4;
End;
For i:=1 To So Do
St:=St+'I';
Writeln;
Writeln('+So thap phan: ',So1);
Writeln('+So La ma : ',St);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Ma_hoa;
Var
St:String;
k:Integer;
i,n:Integer;
Begin
Writeln('CHUONG TRINH MA HOA');
Writeln(' -----------');
Write('-Nhap chuoi: ');
Readln(St);
Write('-Nhap ma so k: ');
Readln(k);
k:=k Mod 26;
For i:= 1 To Length(St) Do
Begin
n:=Ord(St[i]);
If (n >=97) And (n<=122) then
Begin
n:=n+k;
If n > 122 Then
n:=(n Mod 122) + 96;
End;
St[i]:=Chr(n);
End;
Writeln;
Writeln('+Sau khi ma hoa: ',St);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Tim_Xoa;
Var
St,St1:String;
Ch:Char;
i,l,l1:Byte;
Begin
Writeln('TIM VA XOA CAC KY TU TRUNG NHAU TRONG CHUOI');
Writeln(' -----------------');
Writeln;
Write('-Nhap mot chuoi: ');
Readln(St);
St1:=St;
i:=1;
l:=Length(St);
While i <= l Do
Begin
i:=i+1;
If St[i]=St[i - 1] Then
Begin
Writeln('+Ky tu thu: ',i:2,' la: ',St[i],' bi trung lap');
Write('Ban co muon xoa ky tu nay khong (c/k)');
Readln(Ch);
If UpCase(Ch)='C' Then
Begin
Delete(St,i,1);
i:= i - 1;
End;
End;
End;
l1:=Length(St);
Writeln;
Writeln('+Chuoi ban dau : ',St1,' co: ',l:2,' ky tu');
Writeln(' Sau khi xoa ky tu trung nhau');
Writeln(' Chuoi con lai: ',St,' gom: ',l1:2,' ky tu');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Chu_Chay;
Uses Crt;
Const
a='Nha sach Minh Khai, 249 Nguyen Thi Minh Khai, Quan 1, Tp Ho Chi Minh ';
b='Tel: 8 331 124, 9 250 590 ';
c='Chuyen phat hanh cac giao trinh tin hoc phuc vu hoc sinh, sinh vien';
d='Chan thanh cam on quy doc gia';
Function Lap(Kt:Char; N:Integer): String;
Var
Tam:String;
K:Integer;
Begin
Tam:=' ';
For K:=1 To N Do
Tam:=Tam+Kt;
Lap:=Tam;
End;
{--------------}
Procedure WriteXY(X,Y:Integer; St:String);
Begin
GotoXY(X,Y);
Write(St);
End;
{--------------}
Function Min(a,b:Integer):Integer;
Begin
If a < b Then
Min:=a
Else
Min:=b;
End;
{--------------}
Procedure Chuchay(St:String);
Var
k:Integer;
Tin:String;
Begin
Tin:=Lap(' ',68)+'<<' +St+' ';
For k:=1 To Length(Tin) Do
Begin
TextColor(k MOD 16);
WriteXY(6,8,Copy(Tin,k,Min(68,Length(Tin)-k+1)));
Delay(100);
End;
End;
{--------------}
Procedure Khung(x1,y1,x2,y2:Integer);
Var
k:Integer;
Begin
TextColor(14);
WriteXY(x1,y1,#201);
For k:=x1+1 To x2-1 Do
Write(#205);
Write(#187);
WriteXY(x1,y2,#200);
For k:=x1+1 To x2-1 Do
Write(#205);
Write(#188);
For k:=y1+1 To y2-1 Do
Begin
WriteXY(x1,k,#186);
WriteXY(x2,k,#186);
End;
End;
{--------------}
BEGIN
TextBackGround(1);
ClrScr;
TextColor(3+Blink);
GotoXY(30,4);
Writeln('NAM HOC 1999 -2000');
Khung(5,7,75,9);
Repeat
Chuchay(a);
Chuchay(b);
Chuchay(c);
Chuchay(d);
Until KeyPressed;
END.
Program Dem_Tu;
{$V-}
Var
St:String;
Function Sochu(Dong:String):Integer;
Var
dem,i:Integer;
Begin
Dem:=0;
i:=1;
Repeat
While ((UpCase(Dong[i]) < 'A') Or (UpCase(Dong[i]) > 'Z'))
And (I <=Length(Dong)) Do
i:=i+1;
If i <= Length(Dong) Then
Dem:=Dem + 1;
While ((UpCase(Dong[i]) >= 'A') And (UpCase(Dong[i]) <= 'Z'))
And (I <=Length(Dong)) Do
i:=i+1;
Until i > Length(Dong);
Sochu:=Dem;
End;
{---------------------------}
BEGIN
Write('-Nhap mot cau ca dao tuc ngu: ');
Readln(St);
Writeln('-Cau nay co: ',Sochu(St),' tu');
Readln
END.
Program Dem_chuoi;
Var
St:String;
dem:ARRAY['A'.. 'Z'] Of Integer;
i:Integer;
Ch:Char;
Begin
Writeln('DEM SO LAN XUAT HIEN CUA KY TU TRONG CHUOI');
Writeln(' -----------');
Write('-Nhap chuoi: ');
Readln(St);
For i:=1 To Length(St) Do
Dem[UpCase(St[i])]:= Dem[UpCase(St[i])]+1;
Writeln;
Writeln('+Cac ky tu trong chuoi la: ');
For Ch:='A' To 'Z' Do
If Dem[ch] > 0 Then
Writeln('+Chu: ',Ch,' co: ',Dem[Ch],' ky tu' );
Writeln;
Writeln('Bam phim <Enter> de ket thuc');
Readln
End.
Program Vi_Tri_Chuoi;
Var
St1,St2:String;
Begin
Writeln('VI TRI CHUOI CON TRONG CHUOI ME');
Writeln(' Ham Pos');
Writeln(' --------------');
Write('-Chuoi me: ');
Readln(St1);
Write('-Chuoi con: ');
Readln(St2);
Writeln('+Chuoi con bat dau tu vi tri thu: ',Pos(St2,St1),
' trong chuoi me');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program Doi_thap_phan_ra_he_bat_ky;
Var
He10,N,Y,HeN:Word;
He,Tam:String;
Begin
Writeln('DOI SO TU HE THAP PHAN SANG HE BAT KY');
Writeln(' -----------------');
Writeln;
Write('-Nhap so nguyen he thap phan: ');
Readln(He10);
N:=He10;
Write('-Doi sang he nao: ');
Readln(HeN);
He:=' ';
Repeat
Y:=He10 Mod HeN;
If Y < 10 Then
Str(Y, Tam)
Else
Tam:=Chr(Y+55);
He:=Tam + He;
He10:= He10 Div HeN;
Until He10 = 0;
Writeln;
Writeln('+So he 10 la : ',N);
Writeln('+Doi sang he: ',HeN:2,' la: ',He);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.
Program KT_ngay;
CONST
Ngay = [1..31];
Thang = [1..12];
Th31ngay: Set of byte = [1,3,5,7,8,10,12];
BaoLoi : Array[1..3] Of String[30] =('-Ban nhap sai ngay, thang',
'-Thang nay khong co ngay 31','-thang 2 khong co ngay nay');
TYPE
NgayThang = RECORD
Ng, Th : Byte;
Nam : Word;
End;
VAR
Nhatky : NgayThang;
Loi : Array[1..3] Of Boolean;
i : Byte;
Nhuan : Boolean;
BEGIN
With Nhatky Do
Begin
Write('-Nhap ngay = ');
Readln(Ng);
Write('-Nhap thang= ');
Readln(Th);
Write('-Nhap nam = ');
Readln(Nam);
Loi[1] := (NOT(Ng In Ngay)) OR (NOT (Th In Thang));
Loi[2] := (Ng = 31) AND (NOT (Th In Th31Ngay));
Nhuan := ((Nam Mod 4) = 0) AND ((Nam Mod 100) <> 0)
OR ((Nam Mod 400) = 0);
Loi[3] := ((Ng > 29) AND (Th = 2)) OR ((Ng = 29)
AND (th = 2) AND (NOT Nhuan));
End;
For i := 1 To 3 Do
If Loi[i] Then
Writeln(BaoLoi[i]);
Readln
END.
Program Sap_Xep_Tuoi_Giam;
CONST
Max = 50;
Td1 = '|========================|============|';
Td2 = #124+' HO VA TEN '+#124 + ' NAM SINH |';
Td3 = '|------------------------|------------|';
TYPE
HoSo = RECORD
HoTen : String[24];
Ngay : 1..31;
Thang : 1..12;
Nam : 1900..2000;
End;
VAR
Nhanvien :Array[1..Max] Of HoSo;
i,n : 1..Max;
Tam : HoSo;
Kthuc: Boolean;
BEGIN
Writeln('SAP XEP BAN GHI THEO GIAI THUAT NOI BOT');
Writeln('---------------------------------------');
Writeln;
Write('-Co bao nhieu nguoi: ');
Readln(n);
For i := 1 to N Do { Nhap du lieu }
With Nhanvien[i] Do
Begin
Write('-Ho va ten nguoi thu: ',i:2,' = ');
Readln(HoTen);
Write('-Ngay sinh: ');
Readln(Ngay);
Write('-Thang : ');
Readln(Thang);
Write('-Nam : ');
Readln(Nam);
End;
Repeat { Sap xep ban ghi}
KThuc := True;
For i := 1 To N - 1 Do
If (Nhanvien[i].Nam > Nhanvien[i+1].Nam)
OR ((Nhanvien[i].Nam = Nhanvien[i+1].Nam) AND
(Nhanvien[i].Thang > Nhanvien[i+1].Thang))
OR ((Nhanvien[i].Nam = Nhanvien[i+1].Nam) AND
(Nhanvien[i].Thang = Nhanvien[i+1].Thang) AND
(Nhanvien[i].Ngay > Nhanvien[i+1].Ngay)) Then
Begin
Tam:=Nhanvien[i];
Nhanvien[i] := Nhanvien[i+1];
Nhanvien[i+1] := Tam;
KThuc :=False;
End;
Until KThuc;
Writeln;
Writeln(' SAP XEP THEO TUOI');
Writeln;
Writeln(Td1);
Writeln(Td2);
Writeln(Td3);
For i := 1 to N Do
With Nhanvien[i] Do
Writeln(#124, HoTen, #32 :24 - Length(HoTen),
#124,Ngay,' / ',Thang,' / ',nam, #124);
Writeln(Td1);
Readln
END.
Program Tu_dien;
TYPE
Tudien = RECORD
Anh,Viet : String;
End;
VAR
a: Array[1..5] Of TuDien;
St : String;
i : Integer;
TimDuoc : Boolean;
BEGIN
For i := 1 To 5 Do
Begin
Writeln('-Tu thu: ',i);
Write(' +Nghia tieng Anh : ');
Readln(a[i].Anh);
Write(' +Nghia tieng Viet : ');
Readln(a[i].Viet);
End;
Writeln;
Write('*Tu tieng Anh can tim: ');
Readln(St);
TimDuoc :=False;
i := 1;
While (NOT TimDuoc) AND (i <= 5) Do
Begin
If St = a[i].Anh Then
Begin
Write('*Nghia tieng Viet : ',a[i].Viet);
TimDuoc := True;
End;
i := i + 1;
End;
If NOT TimDuoc then
Writeln('Tu nay khong co trong tu dien');
Readln
END.
Program Hoa_Don;
CONST
Max = 100;
TYPE
HoaDon = RECORD
NguoiMua : String[24];
TenHang : String[10];
DonGia : Real;
SoLuong : Integer;
End;
VAR
a : Array[1..Max] Of HoaDon;
DsTenHang : Array[1..Max] Of String[10];
Tam : HoaDon;
Spt, SoTenHang, i, j : Integer;
Tong : Real;
KiemTra : Boolean;
BEGIN
Writeln('HOA DON BAN HANG');
Writeln('----------------');
Writeln;
Spt := 0;
With Tam do
Repeat
Write('-Ten nguoi mua (go 0 de thoat): ');
Readln(NguoiMua);
If NguoiMua <> '0' Then
Begin
Write('-Ten hang: ');
Readln(TenHang);
Write('-Don gia : ');
Readln(DonGia);
Write('-So luong: ');
Readln(SoLuong);
Spt := Spt + 1;
a[Spt] := Tam;
End;
Until NguoiMua = '0';
SoTenHang := 0;
For i := 1 To Spt Do
Begin
KiemTra :=False;
For j := 1 To SoTenHang Do
If DsTenHang[j] = a[i].TenHang Then
KiemTra := True;
If NOT KiemTra Then
Begin
SoTenHang :=SoTenHang + 1;
DsTenHang[SoTenHang] := a[i].TenHang;
End;
End;
Writeln;
For i := 1 To SoTenHang Do
Begin
Tong := 0;
For j := 1 To Spt Do
With a[j] Do
If TenHang = DsTenHang[i] Then
Tong := Tong + (DonGia * Soluong);
Writeln(' +Tong so tien mua: ',DsTenHang[i]:10,' = ',tong:10:2);
End;
Readln
END.
Program Thu_vien;
CONST
Max = 100;
TYPE
ThuVien = RECORD
TenSach : String[30];
TacGia : String[24];
NamXb : 1900..1999;
NguoiMuon : String[24];
End;
VAR
Sach : Array[1..Max] Of ThuVien;
i, n, x : Integer;
Begin
Writeln('QUAN LY SACH CUA THU VIEN');
Writeln('-------------------------');
Write('-So luong sach: ');
Readln(n);
For i := 1 To N Do
With Sach[i] Do
Begin
Write('+Ten sach : ');
Readln(TenSach);
Write('+Tac gia : ');
Readln(TacGia);
Write('+Nam Xuat ban : ');
Readln(NamXb);
Write('+Nguoi muon (Neu khong co ai muon thi bam <Enter>: ');
Readln(NguoiMuon);
End;
Writeln;
x := 0;
For i := 1 To N Do
With Sach[i] Do
Begin
Writeln('-Ten sach: ',TenSach);
Writeln(' +Tac gia : ',TacGia);
Writeln(' +Nam xuat ban : ',NamXb);
If NguoiMuon <> ' ' Then
Begin
Writeln(' +Nguoi muon : ',NguoiMuon);
x := x + 1;
End;
End;
Writeln;
Writeln('+So sach da cho muon: ',x,' quyen');
Readln
End.
Program Tinh_Diem_Xep_Hang;
TYPE
Lop = RECORD
HoTen : String[24];
NamSinh : Integer;
Tb1,Tb2,Tb : Real;
End;
VAR
Hs : Array[1..50] Of lop;
i,j,n,Hang: Integer;
Tam : Lop;
Begin
Writeln('TINH DIEM VA XEP HANG);');
Writeln('Giai thuat noi Buble');
Writeln('--------------------');
Writeln;
Write('-So hoc sinh: ');
Readln(n);
For i := 1 To N Do
With Hs[i] Do
Begin
Write(' +Ho ten hoc sinh thu: ',i:2,' la: ');
Readln(Hoten);
Write(' +Nam sinh: ');
Readln(NamSinh);
Write(' +Diem trung binh hoc ky 1: ');
Readln(Tb1);
Write(' +Diem trung binh hoc ky 2: ');
Readln(Tb2);
Tb :=(Tb1 + Tb2)/2;
Writeln;
End;
For i := 1 To N-1 Do
For j := 1 To N-i Do
If Hs[j].Tb < Hs[j+1].Tb Then
Begin
Tam := Hs[j];
Hs[j] := Hs[j+1];
Hs[j+1] := Tam;
End;
Writeln;
Writeln(' DANH SACH XEP HANG');
Writeln;
Hang := 1;
For i := 1 To N Do
Begin
If (i > 1) And (Hs[i].Tb <> Hs[i-1].Tb) Then
Hang := i;
Writeln(' .Hoc sinh : ',Hs[i].HoTen);
Writeln(' .Nam sinh : ',Hs[i].NamSinh);
Writeln(' .Diem trung binh ca nam : ',Hs[i].Tb:5:2);
Writeln(' .Xep hang ca nam : ',Hang);
End;
Readln
End.
Program Sap_Xep_Tuoi;
TYPE
Ngay_Sinh = RECORD
Ngay,Thang,Nam : Integer;
End;
CongTy = RECORD
HoTen : String[24];
NgaySinh : Ngay_Sinh;
End;
VAR
i,j,n : Integer;
Tam : CongTy;
Nv : Array[1..100] Of CongTy;
Begin
Writeln('SAP XEP THEO TUOI');
Writeln('-----------------');
Writeln;
Write('-So nhan vien: ');
Readln(n);
For i := 1 To N Do
With Nv[i] Do
Begin
Write('-Ho ten nhan vien thu: ',i,' la: ');
Readln(HoTen);
Writeln('-Nhap ngay, thang, nam sinh');
With NgaySinh Do
Begin
Write(' +Ngay : ');
Readln(ngay);
Write(' +Thang: ');
Readln(Thang);
Write(' +Nam : ');
Readln(Nam);
End;
End;
For i := 1 To N-1 Do
For j := 1 To N - i Do
If (Nv[j].Ngaysinh.Nam > Nv[j+1].NgaySinh.Nam) OR
((Nv[j].Ngaysinh.Nam = Nv[j+1].NgaySinh.Nam) AND
(Nv[j].Ngaysinh.Thang > Nv[j+1].NgaySinh.Thang)) OR
((Nv[j].Ngaysinh.Nam = Nv[j+1].NgaySinh.Nam) AND
(Nv[j].Ngaysinh.Thang = Nv[j+1].NgaySinh.Thang) AND
(Nv[j].Ngaysinh.Ngay > Nv[j+1].NgaySinh.Ngay)) Then
Begin
Tam := Nv[j];
Nv[j] := Nv[j+1];
Nv[j+1] := Tam;
End;
Writeln;
Writeln('DANH SACH NHAN VIEN XEP THEO TUOI GIAM DAN');
Writeln;
For i := 1 To N Do
With Nv[i] Do
Writeln('-',Hoten:24,' ,sinh ngay: ',NgaySinh.Ngay,'/',NgaySinh.Thang,'/',NgaySinh.Nam);
Readln
End.
Program Diem_Thi;
CONST
Max = 50;
Td1 = '|========================|======|======|======|';
Td2 = '| HO VA TEN | DIEM | TL1 | TL2 |';
Td3 = '|------------------------|------|------|------|';
Td4 = '|---------------------------------------------|';
TYPE
DiemThi = RECORD
HoTen : String[24];
Diem1 : Real;
Case ThiLai1 : Boolean Of
True : (Diem2 : Real;
Case ThiLai2 : Boolean Of
True : (Diem3 : Real));
End;
VAR
Diem : Array[1..Max] Of DiemThi;
n, i : 1..Max;
BEGIN
Writeln('-So luong sinh vien: ');
Readln(n);
For i := 1 To N Do
With Diem[i] do
Begin
Write('+Ho va ten sinh vien thu: ',i,' = ');
Readln(HoTen);
Write('+Diem thi : ');
Readln(Diem1);
If Diem1 < 5 Then
Begin
ThiLai1 := True;
Write(' -Diem thi lai lan 1= ');
Readln(Diem2);
If Diem2 < 5 Then
Begin
ThiLai2 := True;
Write(' -Diem thi lai lan 2= ');
Readln(Diem3);
End;
End;
End;
Writeln(#32:34,'KET QUA HOC TAP');
Writeln(#32:20,Td1);
Writeln(#32:20,Td2);
Writeln(#32:20,Td3);
For i := 1 To N Do
With Diem[i] Do
Begin
Write(#32:20);
Write(#124,HoTen,#32:24-length(HoTen));
Write(#124,Diem1:6:1);
If Diem1 < 5 Then
Begin
Write(#124,Diem2:6:1);
If Diem2 < 5 Then
Writeln(#124,Diem3:6:1,#124)
Else
Writeln(#124,#32:6,#124);
End
Else
Writeln(#124,#32 :6, #124, #32 :6, #124);
End;
Writeln(#32:20,Td4);
Readln
END.
Program Da_Thuc;
CONST
MaxOrder = 10;
TYPE
PolyNom = RECORD
Bac : Integer;
HeSo : Array[0..MaxOrder] Of Real;
End;
VAR
A,B,C : Polynom;
i : Integer;
{-------------------------}
Procedure Nhap;
Var
i : Integer;
Begin
Repeat
Writeln;
Writeln('Hay nhap 2 da thu A(x), B(x) voi');
Write('-Bac A (phai <= ',MaxOrder,' ) = ');
Readln(A.Bac);
If A.Bac > MaxOrder Then
Writeln(#7,'Bac A phai <= ',MaxOrder,' ! nhap lai ');
Write('-Bac B (phai <= ',MaxOrder,' ) = ');
Readln(B.Bac);
If B.Bac > MaxOrder Then
Writeln(#7,'Bac B phai <= ',MaxOrder,' ! nhap lai ');
Until (A.Bac <= MaxOrder) And (B.Bac <= MaxOrder);
For i := 0 To MaxOrder Do
Begin
A.Heso[i] :=0;
B.Heso[i] :=0;
End;
Writeln;
Writeln('Nhap ca he so cua da thuc A: ');
For i := A.Bac DownTo 0 Do
Begin
Write(' A[',i,'] = ');
Readln(A.heso[i]);
End;
Writeln;
Writeln('Nhap ca he so cua da thuc B: ');
For i := B.Bac DownTo 0 Do
Begin
Write(' B[',i,'] = ');
Readln(B.heso[i]);
End;
End;
{-------------------------}
Procedure Cong(A,B : Polynom; Var C : Polynom);
Var
BacMax :Integer;
Begin
If A.Bac < B.Bac Then
Begin
C.Bac :=B.Bac;
For i := A.Bac + 1 To B.Bac Do
A.Heso[i] := 0
End
Else
Begin
C.Bac := A.Bac;
For i := B.Bac + 1 To A.Bac Do
B.Heso[i] := 0
End;
C.Bac :=A.Bac;
For i := C.Bac To MaxOrder Do
C.Heso[i] := 0;
For i := 0 To C.Bac Do
C.Heso[i] := A.Heso[i] + B.Heso[i];
End;
{-------------------------}
Procedure Nhan(A,B : Polynom; Var C:Polynom);
Var
i,j : Integer;
Begin
For i := 0 To MaxOrder Do
C.Heso[i] := 0;
For i := 0 To A.Bac Do
For j := 0 To B.Bac Do
C.Heso[i+j] := C.Heso[i+j] + A.Heso[i] * B.Heso[j];
C.Bac :=A.Bac + B.Bac;
End;
{-------------------------}
procedure Chia(P, Q :Polynom);
Var
i,k,kk : Integer;
G : Polynom;
Begin
If P.Bac < Q.Bac Then
For i := P.Bac + 1 To Q.Bac Do
P.Heso[i] := 0;
If P.Bac > Q.Bac Then
For i := Q.Bac + 1 To P.Bac Do
Q.Heso[i] := 0;
Write('-Hay cho he so trong ket qua phep chia: ');
Readln(kk);
Writeln('Da thuc ket qua xep theo so mu giam dan. ');
Writeln;
Write('Bac: ');
For k := 0 To kk Do
Write(P.Bac-Q.Bac-k:6);
Writeln;
Write('He so ');
For k := 0 To kk Do
Begin
G.Heso[k] := P.Heso[P.bac] / Q.Heso[Q.Bac];
If Frac(G.Heso[k]) =0 Then
Write(G.Heso[k]:6:0)
Else
Write(G.Heso[k]:6:0);
For i:= Q.Bac DownTo 1 Do
P.Heso[P.Bac-Q.Bac+i] := P.Heso[P.Bac+i-1] - G.Heso[k]*Q.Heso[i-1];
For i := P.Bac-Q.bac Downto 0 Do
P.Heso[i] :=0;
End;
End;
{--------------------------}
BEGIN
Nhap;
Nhan(A,B,C);
Writeln;
Writeln('Cac he so cua da thuc tich: ');
Write('Bac: ');
For i := 0 To C.Bac Do
Write(i:7);
Writeln;
Write('He so: ');
For i := 0 To C.Bac Do
If Frac(C.Heso[i]) = 0 Then
Write(C.Heso[i]:7:0)
Else
Write(C.Heso[i]:7:0);
Writeln;
Writeln;
Chia(A,B);
Readln
END.
Program Ho_So;
CONST
Max = 100;
TYPE
Str = String[24];
HoSo = RECORD
HoTen : Str;
Tuoi : Integer;
Luong : Real;
End;
CongTy = Array[1..Max] Of HoSo;
VAR
Hoten1, Hoten2 : Str;
i,n,TuoiMax,TuoiMin : Integer;
LuongMax, LuongMin,LuongTb : Real;
Nv : CongTy;
Begin
Writeln('HO SO NHAN VIEN');
Writeln('---------------');
Writeln;
Write('-Co bao nhieu nguoi: ');
Readln(n);
For i := 1 To N Do
With Nv[i] Do
Begin
Write('-Ho ten nhan vien thu: ',i:2,' la= ');
Readln(HoTen);
Write('-Tuoi = ');
Readln(Tuoi);
Write('-Bac luong = ');
Readln(Luong);
End;
TuoiMax := Nv[1].Tuoi;
TuoiMin := Nv[1].Tuoi;
LuongMax := Nv[1].Luong;
LuongMin := Nv[1].Luong;
HoTen1 := Nv[1].HoTen;
HoTen2 := Nv[1].HoTen;
LuongTb := Nv[1].Luong;
For i := 2 To N Do
Begin
If Nv[i].Tuoi > TuoiMax Then
TuoiMax := Nv[i].Tuoi
Else
If Nv[i].Tuoi < TuoiMin Then
TuoiMin := Nv[i].Tuoi;
If Nv[i].Luong > LuongMax Then
Begin
LuongMax := Nv[i].Luong;
HoTen1 := Nv[i].HoTen;
End
Else
If Nv[i].Luong < LuongMin Then
Begin
LuongMin := Nv[i].Luong;
HoTen2 := Nv[i].HoTen;
End;
LuongTb := LuongTb + Nv[i].Luong;
End;
Writeln;
Writeln('+Nhan vien co tuoi lon nhat la: ',TuoiMax);
Writeln('+Nhan vien co tuoi nho nhat la: ',TuoiMin);
Writeln('+Nhan vien: ',HoTen1,' co bac luong lon nhat: ',LuongMax:10:2);
Writeln('+Nhan vien: ',HoTen2,' co bac luong nho nhat: ',LuongMin:10:2);
Writeln('+Bac luong trung binh cua toan Cong Ty : ',LuongTb/n:10:2);
Readln
End.
Program Trac_Nghiem;
TYPE
Tracnghiem = RECORD
CauHoi : String;
A,B,C,D : String;
DapAn : Char;
End;
VAR
a:Array[1..5] Of Tracnghiem;
i,dung : Integer;
Traloi : Char;
BEGIN
Writeln('CAU HOI TRAC NGHIEM');
Writeln('-------------------');
Writeln;
Writeln('-Nhap 5 cau hoi,y nghia va dap an');
For i := 1 To 5 Do
With a[i] Do
Begin
Write('-Cau hoi thu: ',i:2,' : ');
Readln(CauHoi);
Write(' +Nghia A: ');
Readln(A);
Write(' +Nghia B: ');
Readln(B);
Write(' +Nghia C: ');
Readln(C);
Write(' +Nghia D: ');
Readln(D);
Write('-Dap an: ');
Readln(DapAn);
DapAn := UpCase(DapAn);
End;
Dung := 0;
Writeln('-Ban chon nghia cho tung cau hoi');
For i := 1 To 5 Do
Begin
Writeln(i,'. ',a[i].CauHoi);
Writeln(' A)',a[i].A);
Writeln(' B)',a[i].B);
Writeln(' C)',a[i].C);
Writeln(' D)',a[i].D);
Write('-Lua cau nao go vao nghia cua cau do: ');
Readln(TraLoi);
If UpCase(TraLoi) = a[i].DapAn Then
Dung := Dung + 1;
End;
Writeln;
Writeln('-So cau tra loi dung: ',Dung);
Readln
END.
Program Tao_Danh_Sach;
Uses Crt;
TYPE
ConTro = ^DanhSach;
DanhSach = RECORD
So : Word;
Next : ConTro;
End;
VAR
First,P,Tam : ConTro;
{----------------------------------}
Procedure KhoiDong;
Begin
First := Nil;
End;
{----------------------------------}
Procedure Nhap;
Var
i : Word;
Begin
Writeln('NHAP CAC SO');
Writeln('Neu khong nhap, go so 0');
i :=0;
Repeat
New(Tam);
Inc(i);
Write('-Nhap so thu: ',i:2,' = ');
Readln(Tam^.So);
Tam^.Next := Nil;
If Tam^.So <> 0 Then
If First = Nil Then
Begin
First := Tam;
P := Tam;
End
Else
Begin
P^.Next := Tam;
P := Tam;
End;
Until Tam^.So =0;
End;
{----------------------------------}
Procedure LietKe;
Begin
Writeln('CAC SO DA NHAP');
Writeln('--------------');
Writeln;
P := First;
While P <> Nil Do
Begin
Write(P^.So:8);
P := P^.Next;
End;
End;
{----------------------------------}
Procedure KetThuc;
Begin
If First <> Nil Then
Release(First);
End;
{----------------------------------}
BEGIN
ClrScr;
Writeln('TAO DANH SACH CAC SO NGUYEN');
Writeln('---------------------------');
Writeln;
KhoiDong;
Nhap;
LietKe;
KetThuc;
Writeln;
Write(' Bam <Enter> . . . ');
Readln;
END.
Program Chen_Xoa_So;
Uses Crt;
CONST
N = 20;
TYPE
ConTro = ^BanGhi;
BanGhi = RECORD
So : Word;
Next : ConTro;
End;
ViTri = 1..n;
VAR
First,P,Tam : ConTro;
V : ViTri;
{----------------------------------}
Procedure KhoiDong;
Begin
First := Nil;
End;
{----------------------------------}
Procedure TaoSo;
Var
i : Byte;
Begin
Randomize;
For i := 1 To n Do
Begin
New(Tam);
Tam^.So := Random(10);
Tam^.Next := Nil;
If i = 1 Then
Begin
First := Tam;
P := Tam;
End
Else
Begin
P^.Next := Tam;
P := Tam;
End;
End;
End;
{----------------------------------}
Procedure XoaSo;
Procedure Xoa5;
Begin
Tam := P;
If P = First Then
Begin
First := P^.Next;
P := P^.Next;
End
Else
Begin
P := First;
While P^.Next <> Tam Do
P := P^.Next;
P^.Next := Tam^.Next;
P := P^.Next;
End;
Dispose(Tam);
End;
Begin
P := First;
While P <> Nil Do
Begin
If P^.So < 5 Then
Xoa5
Else
P := P^.Next
End;
End;
{----------------------------------}
Procedure LietKe;
Begin
P := First;
While P <> Nil Do
Begin
Write(P^.So : 5);
P := P^.Next;
End;
End;
{----------------------------------}
Procedure KetThuc;
Begin
If First <> Nil Then
Release(First);
End;
{----------------------------------}
BEGIN
ClrScr;
Writeln(' XOA CA SO NHO HON 5');
Writeln(' -------------------');
KhoiDong;
TaoSo;
Writeln;
Writeln(' 20 SO TRONG DANH SACH LA: ');
Writeln;
LietKe;
Writeln;
XoaSo;
Writeln;
Writeln(' DANH SACH CAC SO >= 5');
Writeln;
LietKe;
KetThuc;
Writeln;
Writeln;
Write(' Bam <Enter>... ');
Readln
END.
Program Loai_bo;
Uses Crt;
TYPE
Mang = array[1..100] Of Integer;
VAR
i,Na,Nb,x : Integer;
a: mang;
{--------------------------------------}
Procedure LoaiBo(x : Integer; Var a:mang; Var Na : Integer);
Var
i,j : Integer;
Begin
i := 1;
While i <= Na Do
If (a[i] <> x) Then
i := i + 1
Else
Begin
For j := i To Na - 1 Do
a[j] := a[j+1];
Na := Na - 1;
End;
End;
{--------------------------------------}
Begin
ClrScr;
Writeln(' XOA TRI X TRONG DANH SACH');
Writeln(' --------------------------');
Writeln;
Write('-So phan tu: ');
Readln(Na);
Nb := Na;
For i := 1 To Na Do
Begin
Write('-Phan tu thu: ',i:2,' = ');
Readln(a[i]);
End;
Writeln;
Write('+Phan tu can loai bo: ');
Readln(x);
Loaibo(x,a,Na);
If Na = Nb Then
Writeln('Khong tim thay')
Else
Writeln('Da loai bo');
Writeln;
Writeln('DANH SACH CON LAI');
Writeln('-----------------');
Writeln;
For i := 1 To Na Do
Write(a[i],' ');
Writeln;
Write(' Bam <Enter> . . . ');
Readln;
End.
Program Chen_Xoa;
Uses Crt;
TYPE
ConTro = ^Nut;
Nut = RECORD
So : Integer;
Next : ConTro;
End;
VAR
Nut1,Tam : ConTro;
So1 : Integer;
Ch : Char;
{-------------------------------------}
Procedure Chen(Var Nut1 : ConTro; So1 : Integer);
Begin
New(Tam);
Tam^.So :=So1;
Tam^.Next := Nut1;
Nut1 := Tam;
Writeln('Da chen xong, bam <Enter> ... ');
Readln
End;
{-------------------------------------}
Procedure Xoa(Var Nut1 : ConTro; So1 : Integer);
Var
NutTruoc : ConTro;
TimThay : Boolean;
Begin
Tam := Nut1;
NutTruoc := Nil;
TimThay := False;
While (Tam <> Nil) And (Not TimThay) Do
If Tam^.So = So1 Then
TimThay := True
Else
Begin
NutTruoc := Tam;
Tam := Tam^.Next;
End;
If TimThay Then
Begin
If NutTruoc = Nil Then
Nut1 := Tam^.Next
Else
NutTruoc^.Next := Tam^.Next;
Dispose(Tam);
Write(' Da xoa xong, bam <Enter> ... ');
Readln
End
Else
Begin
Write(' Khong tim thay, bam <Enter> ... ');
Readln
End;
End;
{-------------------------------------}
Procedure Xem(Var Nut1 : ConTro);
Begin
Tam := Nut1;
While Tam <> Nil Do
Begin
Write(Tam^.So : 6);
Tam := Tam^.Next;
End;
Writeln;
Write(' Xem xong, bam <Enter> . . .');
Readln
End;
{-------------------------------------}
BEGIN
ClrScr;
Writeln(' NHAP, CHEN, XEM, XOA SO NGUYEN');
Writeln(' ------------------------------');
Writeln;
Nut1 := Nil;
Repeat
New(Tam);
Write('-Nhap so: ');
Readln(Tam^.So);
Tam^.Next := Nut1;
Nut1 := Tam;
Write(' Nhap nua khong ? (c/k) ');
Readln(Ch);
Until UpCase(Ch)= 'K';
Repeat
ClrScr;
Repeat
Writeln;
Writeln('CHON CHUC NANG');
Writeln('--------------');
Writeln('1-Chen ');
Writeln('2-Xoa ');
Writeln('3-Xem ');
Writeln('4-Ket thuc ');
Ch := Readkey;
Until Ch in ['1'..'4'];
Case Ch Of
'1' : Begin
Write('-So muon chen: ');
Readln(So1);
Chen(Nut1,So1);
End;
'2' : Begin
Write('-So muon xoa: ');
Readln(So1);
Xoa(Nut1,So1);
End;
'3' : Begin
Xem(Nut1);
End;
End;
Until Ch = '4';
END.
Program Nhap_Du_Lieu;
Uses Crt;
Type
HoSo = RECORD
Holot : String[17];
Ten : String[7];
Tuoi : 18..60;
ChucVu: String[20];
BacLuong : 300000..900000;
End;
Var
f : File Of HoSo;
Nv : HoSo;
ans : Char;
Begin
ClrScr;
Writeln('NHAP DU LIEU VAO TAP TIN LUONG.DAT');
Writeln('----------------------------------');
Writeln;
Assign(f,'LUONG.DAT');
Rewrite(f);
Repeat
With Nv Do
Begin
Write('-Ho lot: ');
Readln(Holot);
Write('-Ten : ');
Readln(Ten);
Write('-Tuoi : ');
Readln(tuoi);
Write('-Chuc vu : ');
Readln(ChucVu);
Write('-Bac luong: ');
Readln(BacLuong);
Write(f,Nv);
End;
ans := Readkey;
Until ans = #27;
Close(f);
End.
Program Doi_he_2;
Const
KyTuHe2:array[0..1] Of Char ='01';
Var
SoWord:Word;
SoBinary:String[16];
i:byte;
Begin
Writeln('DOI SO NGUYEN KIEU WORD RA HE NHI PHAN');
Writeln('--------------------------------------');
Writeln;
Write('-Nhap so kieu Word: ');
Readln(SoWord);
SoBinary[0]:=#16;
For i:=15 DownTo 0 Do
If (SoWord AND (1 SHL i)) = (1 SHL i) Then
SoBinary[16-i]:= KyTuHe2[1]
Else
SoBinary[16-i]:= KyTuHe2[0];
Writeln('+So nguyen kieu Word = ',soWord);
Writeln('+Doi ra so he nhi phan= B ',SoBinary);
Writeln;
Writeln(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Nhan_ma_tran;
Const
Max=10;
Type
Matran=Array[1..Max,1..Max] Of Integer;
Var
A,B,C:Matran;
hang1,cot1,i,j,m,n,q:Integer;
Begin
Writeln('NHAN MA TRAN');
Writeln('------------');
Writeln;
Writeln('MA TRAN A:');
Write('-So hang = ');
Readln(m);
Write('-So cot = ');
Readln(n);
For i:=1 To m Do
For j:=1 To n Do
Begin
Write('+Phan tu A[',i,',',j,' = ');
Readln(a[i,j]);
End;
Cot1:=m;
Hang1:=m;
Writeln;
Writeln('MA TRAN B:');
Write('-So hang = ');
Readln(m);
Write('-So cot = ');
Readln(n);
For i:=1 To m Do
For j:=1 To n Do
Begin
Write('+Phan tu B[',i,',',j,' = ');
Readln(b[i,j]);
End;
For i:=1 To Hang1 Do
For j:=1 To n Do
Begin
c[i,j]:=0;
For q:=1 To Cot1 Do
c[i,j]:= c[i,j] + a[i,q] * b[q,j];
End;
For i:=1 to hang1 Do
Begin
For j:= 1 To n Do
Write((c[i,j]):8);
Writeln;
End;
Readln
End.
Program Giai_he_PT_tuyen_tinh;
Var
A:Array[1..2, 1..2] Of Real;
C:Array[1..2] Of Real;
x,y,dt,dtx,dty:Real;
i,j:Integer;
Begin
Writeln('GIAI HE PT TUYEN TINH 2 AN');
Writeln('--------------------------');
Writeln;
Writeln('-Nhap cac he so A cua he phuong trinh: ');
For i:=1 to 2 Do
For j:=1 To 2 Do
Begin
Write('+Phan tu A[',i,',',j,']= ');
Readln(a[i,j]);
End;
Writeln;
Writeln('-Nhap cac he so C cua he phuong trinh: ');
For i:=1 to 2 Do
Begin
Write('+Phan tu C[',i,']= ');
Readln(c[i]);
End;
Writeln;
{Giai he phuong trinh}
Dt:= a[1,1]*a[2,2]-a[1,2]*a[2,1]; {Dt: Dinh thuc}
Dtx:=c[1]*a[2,2]-c[2]*a[2,1];
Dty:=a[1,1]*c[2]-a[1,2]*c[1];
If Dt <> 0 Then
Begin
x:=Dtx / Dt;
y:=Dty / Dt;
Writeln('X= ',x);
Writeln('Y= ',y);
End
Else
Begin
If (Dtx=0) And (Dty=0) Then
Writeln(#7,#7,#7,' Co vo so nghiem')
Else
Writeln(#7,#7,#7,'Vo nghiem');
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Ma_tran_vuong;
Uses Crt;
Var
a:Array[1..10, 1..10] Of Integer;
i,j:Integer;
Begin
Writeln('MA TRAN VUONG 10 x 10 PHAN TU');
Writeln('-----------------------------');
ClrScr;
Window(10,5,60,25);
For i:= 1 To 10 Do
Begin
For j:=1 To 10 Do
Begin
If i=j Then
a[i,j]:=i
Else
a[i,j]:=0;
Write(a[i,j]:5);
End;
Writeln(#10)
End;
Writeln;
Writeln(' Bam phim <Enter> de ket thuc ');
Readln
End.
Program Thu_Vien;
Uses Crt;
TYPE
ConTro = ^ThuVien;
ThuVien = RECORD
TenSach : String[30];
TacGia : String[24];
Namxb : Byte;
NguoiMuon: String[24];
Next : ConTro;
End;
VAR
First,Last,Newp : ConTro;
ds,dm : Integer;
Ch : Char;
HeapTop : ^Integer;
BEGIN
ClrScr;
GotoXY(5,25);
Write('Bam <Enter> de tiep tuc, bam <Esc> de thoat');
Window(1,1,80,24);
Writeln('QUAN LY THU VIEN');
Writeln('----------------');
Writeln;
ds := 0;
dm := 0;
First := Nil;
Mark(Heaptop);
Repeat
New(Newp);
With Newp^ Do
Begin
Write('-Ten sach : ');
Readln(TenSach);
If TenSach <> '' Then
Begin
ds := ds + 1;
Write('-Tac Gia: ');
Readln(TacGia);
Write('-Nam xuat ban : ');
Readln(Namxb);
Write('-Nguoi muon (Khong co ai muon thi bam <Enter>: ');
Readln(NguoiMuon);
If NguoiMuon <> '' Then
dm := dm + 1;
End;
End;
If First = Nil Then
First := Newp
Else
Last^.Next := Newp;
Last :=Newp;
Last^.Next := Nil;
Ch := ReadKey;
Until Ch = #27;
ClrScr;
Writeln('QUAN LY THU VIEN');
Writeln('----------------');
While First <> Nil Do
With First^ Do
Begin
Writeln('-Ten sach: ',TenSach);
Writeln('-Tac gia : ',TacGia);
Writeln('-Nam Xuat ban: ',Namxb);
Writeln('-Nguoi muon : ',NguoiMuon);
First := Next;
End;
Writeln;
Writeln('+Tong so sach: ',Ds);
Writeln('+So sach cho muon: ',Dm);
Release(HeapTop);
Writeln;
Write(' Bam <Esc> de thoat');
Readln
END.
Program Phan_So_2;
Uses PhanSo2;
Var
X,Y : T_PhanSo2;
so1,so2 : Real;
Begin
Writeln('SO SANH, CONG 2 SO THUC DUOI DANG PHAN SO');
Writeln('----------------------------------------');
Writeln;
Write('-Nhap so thu nhat: ');
Readln(so1);
Write('-Nhap so thu hai : ');
Readln(so2);
X.KhoiDong;
Y.KhoiDong;
X.Doi(So1);
Y.Doi(So2);
Writeln;
Write('-Doi so thu nhat ra phan so la : ');
X.Xuat;
Writeln;
Write('-Doi so thu hai ra phan so la : ');
Y.Xuat;
Writeln;
Writeln;
If X.LonHon(Y) Then
Writeln('-So thu nhat lon hon so thu hai');
If Y.LonHon(X) Then
Writeln('-So thu hai lon hon so thu nhat');
Writeln;
X.Cong(Y);
Write('-Tong 2 phan so la : ');
X.Xuat;
Writeln;
Write(' Bam <Enter> . . . ');
Readln
End.
Program Do_Thi;
Uses Graph;
Var
Gd,Gm,j,mx,my : Integer;
i,x,y : Real;
Xasp,Yasp,CenterX,CenterY : Word;
Pattern : Word;
Palette : PaletteType;
{----------------------------------}
Function Adjasp(Value: Integer) : Integer;
Begin
Adjasp := (LongInt(Value)*Xasp) Div Yasp;
End;
{----------------------------------}
BEGIN
Gd := Detect;
InitGraph(Gd,Gm,'C:\BP\BGI');
If GraphResult <> GrOk Then
Halt;
SetGraphMode(0);
SetBkColor(Blue);
GetPalette(Palette);
SetAllPalette(Palette);
GetAspectRatio(Xasp,Yasp);
CenterX := GetMaxX Div 2;
CenterY := GetMaxY Div 2;
SetTextJustify(CenterText,CenterText);
SetColor(2);
Line(0,CenterY,GetMaxX-25,CenterY);
Line(CenterX,20,CenterX,GetMaxY);
OutTextXY(CenterX-10,CenterY+5,'0');
OutTextXY(GetMaxX-16,CenterY,'>X ');
SetTextStyle(DefaultFont,VertDir,0);
OutTextXY(CenterX,18,'>');
SetTextStyle(DefaultFont,HorizDir,0);
OutTextXY(CenterX,8,'Y');
i := 0;
SetColor(2);
While i <= GetMaxX Do
Begin
x :=(i-160)/20;
mx := Round(i);
y := (sin(x))*(Sin(x))*(Sin(x));
my := CenterY - Adjasp(Round(y*20));
If abs(my) < 200 Then
PutPixel(mx,my,14);
i := i+(2/7);
End;
Rectangle(CenterX+10,CenterY+10,GetMaxX-10,GetMaxY-15);
SetViewPort(CenterX+9,CenterY+9,GetMaxX-9,GetMaxY-16,ClipOn);
SetTextStyle(2,0,4);
OutTextXY(48,12,'He truc toa do');
SetTextStyle(1,0,3);
OutTextXY(60,40,'DESCARTES');
Readln;
CloseGraph;
END.
Bạn đang đọc truyện trên: AzTruyen.Top