GIAO TRINH LY THUYET VA BAI TAP TURBO PASCAL-CHUONG 1 Dang Thanh Tuan(15/3/2004) **********0101********** Program PTB2; Var a,b,c:Integer; delta,x1,x2:Real; Begin Writeln('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; readln End. **********0102********** Program Ao_thu; Begin Writeln(' 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'); Readln End. **********0103********** Program So_hoc; Var so1,so2,tong,hieu,tich:Integer; thuong:Real; Begin Write('-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); Readln End. **********0104********** Program Pithagore; Var a,b :Integer; c:Real; Begin Writeln(' 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); Readln End. **********0105********** 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. **********0106********** Program Lenh_Write; Begin Write('Nam '); Write('Quoc '); Write('Son '); Write('Ha '); Write('Nam ');
Write('De '); Write('Cu '); Readln End. **********0107 Program Lenh_Writeln; Begin Writeln('Nam '); Writeln('Quoc '); Writeln('Son '); Writeln('Ha '); Writeln('Nam '); Writeln('De '); Writeln('Cu '); Readln End. *********0108********* Program Tam_giac_Pascal; Begin Writeln(' 1'); Writeln(' 1 1'); Writeln(' 1 2 1'); Writeln(' 1 3 3 1'); Writeln('1 4 6 4 1'); Readln End. *********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'); Readln End. *********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;
End.
Writeln('------------------------------'); Writeln('XUAT DU LIEU RA MAN HINH'); Writeln(ky_tu); Writeln(chuoi); Writeln(so_nguyen); Writeln(so_thuc); Readln