Pascal | Lập thủ tục nhập ba số thực dương a , b , c từ bàn phím

Pascal | Lập thủ tục nhập ba số thực dương a , b , c từ bàn phím

Viết chương trình thực hiện lần lượt các công việc sau:

- Lập thủ tục nhập ba số thực dương a , b , c từ bàn phím .

- Lập thủ tục kiểm tra xem ba số trên có lập thành ba cạnh của tam giác hay không ?

- Viết hàm tính diện tích của tam giác .

- Viết hoàn thiện chương trình chính.

Chương trình

Program Tam_Giac;

Uses crt;

Var a,b,c : Integer;

{ 1. Thu tuc nhap}

Procedure NhapABC (Var a, b, c : Integer);

Begin

    Write( 'Nhap a:' ); Readln( a );

    Write( 'Nhap b:' ); Readln( b );

    Write( 'Nhap c:' ); Readln( c );

End;

{ 2. Ham tinh dien tich}

Function Dientich( a, b, c:Integer ) : Real;

Var dt,p : Real;

Begin

     p := (a+b+c)/2;

     dt := sqrt(p* (p-a)*(p-b)*(p-c));

     Dientich := dt;

End;

{ 3. Thu tuc kiem tra va In kqua tinh dien tich (neu la tam giac) }

Procedure KiemTra_InDienTich ( a,b,c:Integer);

Begin

     If ((a+b>c) and (b+c>a) and (a+c>b)) then

         Writeln(' Ba canh tren tao thanh tam giac.dien tich', Dientich(a,b,c) )

     Else

         Writeln('Ba canh tren khongtao thanh tam giac');

End;

{ 3. Than chuong trinh chinh }

BEGIN

     NhapABC(a,b,c);

     KiemTra_InDienTich (a,b,c);

END.
Bạn thấy bài viết này như thế nào?: 
Average: 10 (3 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
How to batch assign taxonomy terms to nodes using Views Bulk Operations

Hướng dẫn gắn taxonomy terms to nodes sử dụng Views Bulk Operations

First off, make sure you have the 2 modules installed. Drush will quickly take care of that for you if you don't have them yet:

50 phím tắt hữu ích cho người dùng Windows và MAC

50 phím tắt hữu ích cho người dùng Windows và MAC

Nếu bạn chưa có thói quen sử dụng phím tắt, hãy cố gắng rèn luyện và ghi nhớ chúng nha.

Thi lấy chứng chỉ: Acquia Certified Developer Exam Blueprint

Thi lấy chứng chỉ: Acquia Certified Developer Exam Blueprint

The Acquia Certified Developer exam is intended for Acquia customers, partners, and employees who perform a Developer role. This exam validates a candidate’s ability to:

Công ty diệt chuột T&C

 

Diet con trung