Giải bài toán cổ Trăm Trâu với Pascal

Giải bài toán cổ Trăm Trâu với Pascal

Trâu đứng ăn năm

Trâu nằm ăn ba

Lụ khụ trâu già

Ba con một bó

Trăm con ăn cỏ

Trăm bó no nê.

Hỏi có bao nhiêu trâu đứng , trâu nằm , trâu già ?

Code:

Program Tram_trau;
Var
    dung,nam,gia,co,trau:Integer;
Begin
    Writeln('BAI TOAN CO DIEN');
   Writeln('Tram trau tram co');
   Writeln('Trau dung an 5');
   Writeln('Trau nam an 3');
   Writeln('Ba trau gia an 1');
   Writeln('----------------');
   Writeln('           Bai toan nay co cac loi giai sau');
   For dung:=0 To 20 Do
       For nam:=0 To 33-dung Do
          For gia:=0 To (100-(dung+nam)) Do
             Begin
                co:=5*dung+3*nam+(gia Div 3);
               trau:=dung+nam+gia;
               If (gia Mod 3 =0) And (trau=100) And ( co=100) Then
                   Writeln('-Trau dung ',dung,' con, -Trau nam ',nam,' con, -Trau gia ',gia,' con');
            End;
   Writeln;
   Writeln('   Bam phim <Enter> de ket thuc');
   Readln
End.   
Bạn thấy bài viết này như thế nào?: 
Average: 6.2 (21 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

 
Giới thiệu sơ lược Apache Hadoop

Giới thiệu sơ lược Apache Hadoop

Các cỗ máy tìm kiếm như Google chọn lọc thông tin và trả về kết quả trong tích tắc. Kỹ thuật thường được sử dụng là chia nhỏ nhiệm vụ(job) để hàng loạt máy tính cùng nhau thực hiện. Kỹ thuật này cũng được biết đến với tên gọi Cloud computing. Tìm hiểu hadoop sẽ giúp chúng ta làm quen với Cloud computing.

Giới thiệu markup tốt nhất trong Drupal 8

Giới thiệu markup tốt nhất trong Drupal 8

In previous versions of Drupal, developers had to be very careful not to cause a security issue by printing

Drupal features

Một số tính năng của Drupal

Drupal is a fully featured content management system that can be infinitely enhanced through the installation of contributed modules or by customised development.

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

 

Diet con trung