pascal
Program CTC_Tonghieu; { Chuan }
Uses Dos;
Var
A,B:Integer;
Z:Real;
Procedure Nhap;
Begin
Write('Nhap A = ');Readln(A);
Write('Nhap B = ');Readln(B);
End;
{**************************}
Procedure Tong(X,Y:Integer);
Begin
Writen'Tong 2 So La: ',X+Y);
End;
{**************************}
Procedure Hieu(X,Y:Integer);
Begin
Writeln('Hieu 2 So La: ',X-Y);
End;
{**************************}
Procedure Tich(X,Y:Integer);
Begin
Writeln('Tich 2 So La: ',X*Y);
End;
{**************************}
Procedure Thuong(X,Y:Integer);
Begin
If Y<>0 Then
Writeln('Thuong 2 So La: ',X/Y:3:1)
Else
Writeln('Khong Thuc Hien Duoc Phep Chia Cho 0 ');
End;
(**********************************)
Begin
Writeln('TÝnh Tong, h,t,t.. 2 So );
Nhap;
Tong(A,B);Writeln;
Writeln('TÝnh Hieu 2 So );
Hieu(A,B);Writeln;
Writeln('TÝnh TÝch 2 So );
Tich(A,B);
Writeln('TÝnh Thuong 2 So );
Thuong(A,B);
Readln;
End.
(4)
Procedure Nhap_mang(var x:mang;i,n:integer);
Begin
Write('Nhap N = '); readln(n);
Writeln('Nhap cac phan tu');
For i:=1 to n do
Begin
Write('x[',i,'] = ');readln(x[i]);
End;
Writeln('mang da cho: ');
For i:=1 to n do
Write(x[i], '');
End;
(5)
Procedure sapxep(var x:mang;i,j,n,tg:integer);{ sap xep- LUA CHON}
Begin
For i:=2 to n do
For j:=1 to i -1 do
If x[i] < x[j] then
Begin
Tg:=x[j];
X[j]:=x[i];
X[i]:=tg;
End;
End;
(6)
Procedure IN( var x: mang; i,n: integer );
Begin
Writeln('In ra mang da SX : ');
For i:=1 to n do
Write(x[i], '');
Readln;
End;
(7)
Program Nhap_Sx_In;
Uses dos;
Type
Mang: array[1..100] of integer;
Var
X: mang;
N: integer;
(***************************************)
Procedure Nhap_mang(var x:mang;i,k:integer);
Begin
Writeln('Nhap cac phan tu');
For i:=1 to k do
Begin
Write('x[',i,'] = ');readln(x[i]);
End;
End;
(***************************************)
Procedure sapxep(var x:mang;i,j,k,tg:integer);{ sap xep- LUA CHON}
Begin
For i:=2 to k do
For j:=1 to i -1 do
If x[i] < x[j] then
Begin
Tg:=x[j];
X[j]:=x[i];
X[i]:=tg;
End;
End;
(***************************************)
Procedure IN( var x: mang; i,k: integer );
Begin
Writeln('In ra mang : ');
For i:=1 to k do
Write(x[i], '');
Readln;
End;
(**************************************)
BEGIN
Write(‘ Cho sè phÇn tö n = ‘); Readln(n);
Writeln(‘ Nhap mang ‘);
Nhap_mang(x,i,n);
Writeln;
Writeln( ‘In ra D·y cha s¾p : ’);
In(x,i,n);
Writeln( ‘In ra D·y ®· s¾p : ’);
Sapxep( x,i,j,k,tg );
In(x,i,n);
Readln;
END.
(8)
Program gptb_2;
Uses dos;
Var
L,m,n: integer;
Delta,x1,x2, can: real;
(****************************)
Procedure gptb2(a,b,c:real);
Var
X1,x2,delta,can: real;
(*****************************)
Procedure delta_duong;
Begin
Can:=sqrt(delta);
X1:= (-b+can)/(2*a);
X2:= (-b-can)/(2*a);
Writeln(' pt conghiem x1 = ',x1:5:2);
Writeln(' pt conghiem x2 = ',x2:5:2);
End;
(****************************)
Procedure delta_am;
Begin
Writeln(' ptvonghiem ')
End;
(****************************)
Procedure delta_khong;
Begin
Writeln(' pt conghiem kep x1 = x2 =',-b/(2*a):5:2)
End;
(****************************)
Begin(* than ctc gptb2 *)
Delta:=b*b -4*a*c;
If delta = 0 then delta_khong;
If delta > 0 then delta_duong;
If delta < 0 then delta_am;
End;(* ket thuc ctc gotb2 *)
Begin(* than chuong trinh chinh *)
Writeln('giai pt bac 2 ');
Write('nhap l = ');readln(l);
Write('nhap m = ');readln(m);
Write('nhap n = ');readln(n);
Gptb2(l,m,n);
Readln;
END.
(9)
Program gptb_2;
Uses dos;
Var
L,m,n: integer;
Delta,x1,x2, can: real;
(****************************)
Procedure gptb2(a,b,c:real);
Var
X1,x2,delta,can: real;
(*****************************)
Procedure delta_duong;
Begin
Can:=sqrt(delta);
X1:= (-b+can)/(2*a);
X2:= (-b-can)/(2*a);
Writeln(' pt conghiem x1 = ',x1:5:2);
Writeln(' pt conghiem x2 = ',x2:5:2);
End;
(****************************)
Procedure delta_am;
Begin
Writeln(' ptvonghiem ')
End;
(****************************)
Procedure delta_khong;
Begin
Writeln(' pt conghiem kep x1 = x2 =',-b/(2*a):5:2)
End;
(****************************)
Begin(* than ctc gptb2 *)
Delta:= b*b -4*a*c;
If delta = 0 then delta_khong;
If delta > 0 then delta_duong;
If delta < 0 then delta_am;
End;(* ket thuc ctc gotb2 *)
Begin(* than chuong trinh chinh *)
Writeln('giai pt bac 2 ');
Write('nhap l = ');readln(l);
Write('nhap m = ');readln(m);
Write('nhap n = ');readln(n);
Gptb2(l,m,n);
Readln;
END.
Bạn đang đọc truyện trên: truyentop.pro