Bài tập Pascal

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.

 

doc15 trang | Chuyên mục: Pascal | Chia sẻ: dkS00TYs | Lượt xem: 2339 | Lượt tải: 2download
Tóm tắt nội dung Bài tập Pascal, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
ln;
   Writeln('    Bam phim de ket thuc');
   Readln
End.
Bài 8
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 de ket thuc');
   Readln
End.
Bài 9
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 de ket thuc');
   Readln
End.
Bài 10
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 de ket thuc');
   Readln
End.
Bài 11
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 de ket thuc');
   Readln
End.
Bài 12
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 de ket thuc');
   Readln
End.
Bài 13
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 de ket thuc');
   Readln
End.
Bài 14
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 de ket thuc');
   Readln
End.
Bài 15
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 de ket thuc');
   Readln
End.
Chương 3.
Bài 1
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.
Bài 2
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.
Bài 3
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.
Bài 4
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.
Bài 5
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.
Bài 6
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.
Bài 7
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.
Bài 8
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.
Bài 9
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.
Bài 10
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.
Bài 11
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.
Bài 12
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.
Bài 13
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.
Bài 14
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.
Nam Duy Nguyen
(suu tam)

File đính kèm:

  • docBài tập Pascal.doc
Tài liệu liên quan