Giáo trình lý thuyết và bài tập Pascal
GIAO TRINH LY THUYET VA BAI TAP TURBO PASCAL-CHUONG 1Dang Thanh Tuan(15/3/2004)**********0101**********Program PTB2;Vara,b,c:Integer; delta,x1,x2:Real;BeginWriteln('GIAI PHUONG TRINH BAC HAI'); 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 x1:=(-b-sqrt(delta))/2*a; x2:=(-b+sqrt(delta))/2*a; Writeln('*Nghiem thu nhat X1= ',x1:6:2); Writeln('*Nghiem thu hai X2= ',x2:6:2); End; readlnEnd.**********0102**********Program Ao_thu;BeginWriteln(' BAI THO AO THU');Writeln('Ao thu lanh leo nuoc trong veo'); Writeln('Mot chiec thuyen cau be teo teo'); Writeln('Song biec theo lan hoi gon ty'); Writeln('La vang truoc gio se dua veo'); Writeln(' NGUYEN KHUYEN');ReadlnEnd.**********0103**********Program So_hoc;Varso1,so2,tong,hieu,tich:Integer; thuong:Real;BeginWrite('-Nhap so thu nhat = '); Readln(so1); Write('-Nhap so thu hai = '); Readln(so2); tong := so1 + so2; hieu := so1 - so2; tich := so1 * so2; thuong := so1 / so2; Writeln('*Tong cua hai so ',so1,' va ',so2,' = ',tong); Writeln('*Hieu cua hai so ',so1,' va ',so2,' = ',hieu); Writeln('*Tich cua hai so ',so1,' va ',so2,' = ',tich); Writeln('*Thuong cua hai so ',so1,' va ',so2,' = ',thuong:6:2); ReadlnEnd.**********0104**********Program Pithagore;Vara,b :Integer; c:Real;BeginWriteln(' CHUONG TRINH TINH CANH HUYEN TAM GIAC VUONG'); Writeln(' theo dinh ly Pithagore');Write('-Nhap canh a = ');Readln(a);Write('-Nhap canh b = ');Readln(b);c := Sqrt((a*a) + (b*b));Writeln('*Canh huyen = ',c:6:2);ReadlnEnd.**********0105**********Program Phep_Cong;Varso1,so2,so3,tong :Integer;BeginWriteln(' 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);ReadlnEnd.**********0106**********Program Lenh_Write;BeginWrite('Nam '); Write('Quoc '); Write('Son '); Write('Ha '); Write('Nam '); Write('De '); Write('Cu '); ReadlnEnd.**********0107Program Lenh_Writeln;BeginWriteln('Nam '); Writeln('Quoc '); Writeln('Son '); Writeln('Ha '); Writeln('Nam '); Writeln('De '); Writeln('Cu '); ReadlnEnd.*********0108*********Program Tam_giac_Pascal;BeginWriteln(' 1'); Writeln(' 1 1'); Writeln(' 1 2 1'); Writeln(' 1 3 3 1'); Writeln('1 4 6 4 1'); ReadlnEnd.*********0109*********Program Hinh_tron;Var r:Integer; s:Real;Begin Writeln('CHUONG TRINH TINH DIEN TICH HINH TRON'); Write('-Cho biet ban kinh = '); Readln(r); s:=3.1416 * r * r; Writeln('*Dien tich hinh tron = ',s:6:2,' met vuong'); ReadlnEnd.*********0110**********Program Khuon_dang;Var ky_tu :Char; chuoi :string[24]; so_nguyen:Integer; so_thuc:Real;Begin Writeln('CHUONG TRINH XUAT DU LIEU THEO KHUON DANG'); Write('-Nhap mot ky tu = '); Readln(ky_tu); Write('-Nhap ho ten = '); Readln(chuoi); Write('-Nhap mot so nguyen = '); Readln(so_nguyen); Write('-Nhap mot so thuc = '); Readln(so_thuc); Writln; Writeln('------------------------------'); Writeln('XUAT DU LIEU RA MAN HINH'); Writeln(ky_tu); Writeln(chuoi); Writeln(so_nguyen); Writeln(so_thuc); ReadlnEnd. . GIAO TRINH LY THUYET VA BAI TAP TURBO PASCAL- CHUONG 1Dang Thanh Tuan(15/3/2004)**********0101**********Program PTB2;Vara,b,c:Integer;. Writeln('Cu '); ReadlnEnd.*********0108*********Program Tam_giac _Pascal; BeginWriteln(' 1'); Writeln(' 1 1');