tài liệu tuyển tập bài tập chuyên đề pascal giúp các bạn củng cố kiến thức và ôn thi tốt hơn.
Nội dung trích xuất từ tài liệu:
Bài tập chuyên đề Pascal
BÀI TẬP PASCAL
Chủ nhật, 30/11/2008 12:23 pm
BÀI TẬP PASCAL
Chương 1.
Bài 1
Program Ca_dao;
Begin
Writeln('Trong dam gi dep bang sen,');
Writeln('La xanh bong trang lai chen nhi vang,');
Writeln('Nhi vang bong trang la xanh.');
Writeln('Gan bun ma chang hoi tanh mui bun');
Readln
End.
Bài 2
Program Tam_giac;
Begin
Writeln('*********');
Writeln(' *******');
Writeln(' *****');
Writeln(' ***');
Writeln(' *');
Readln
End.
Bài 3
Program Phep_Tru;
Var
so1,so2,hieu :Integer;
Begin
Writeln(' CHUONG TRINH THUC HIEN PHEP TRU SO HOC');
Writeln(' co toi da 4 ky so');
Write('-Nhap so thu nhat = ');
Readln(so1);
Write('-Nhap so thu hai = ');
Readln(so2);
hieu:= so1-so2;
Writeln;
Writeln;
Writeln('-------------------------------');
Writeln;
Writeln(' ',so1:4);
Writeln(' - ',so2:4);
Writeln(' -----');
Writeln(' = ',hieu:5);
Readln
End.
Bài 4
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.
Bài 5
rogram 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.
Bài 6
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.
Bài 7
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.
Bài 8
Program Hinh_cau;
Var
s:integer;
r,v:Real;
Begin
Writeln('CHUONG TRINH TINH THE TICH HINH CAU');
Writeln('---------------------------------');
Write('Cho biet dien tich hinh tron = ');
Readln(s);
r:=Sqrt(s/4*3.1416);
v:=4/3 * 3.1416 *r*r*r;
Writeln('*The tich hinh cau la : ',V:6:2,' met khoi');
Readln
End.
Bài 9
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.
Bài 10
Program Pignet;
Var
Ten:String;
Tuoi:Integer;
lon,nho,tb,tl,cao,pig:Real;
Begin
Writeln('CHUONG TRINH TINH PIGNET');
Writeln('------------------------');
Write('-Cho biet ho ten : ');
Readln(ten);
Write('-Cho biet tuoi : ');
Readln(tuoi);
Write('-Cho biet chieu cao : ');
Readln(cao);
Write('-Cho biet trong luong : ');
Readln(tl);
Write('-So do vong nguc luc hit vao = ');
Readln(lon);
Write('-So do vong nguc luc tho ra = ');
Readln(nho);
tb := 0.5 * (lon-nho);
pig := cao - (tb + tl);
Writeln;
Write('+Ong (Ba) : ',ten:24);
Writeln(' , ',tuoi,' tuoi');
Writeln('+Co so do Pignet = ',pig:6:2);
Readln
End.
Bài 11
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 de ket thuc');
Readln
End.
Bài 12
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 de ket thuc');
Readln
End.
Bài 13
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 de ket thuc');
Readln
End.
Bài 14
Program Tinh_do_dai_vec_to;
Var
x,y,z:Integer;
l:Real;
Begin
...