Computer Science Blog

June 12, 2007

Program untuk menampilkan semua solusi bilangan bulat tidak negative

Filed under: Pascal Programming

Buatlah sebuah program untuk menampilkan semua solusi bilangan bulat tidak negative dari persamaan :

 X + Y + Z = 25

 Contoh :

X = 0, Y = 0, Z = 25 à 0 + 0 + 25 = 25

X = 0, Y = 1, Z = 24 à 0 + 1 + 24 = 25

 
Penyelesaian :

Program Bilangan;

uses wincrt;

 

var

    i,j,k : byte;

    sum   : byte;

    jumlah: integer;

 

 begin

      jumlah := 0;

      for i:=0 to 25 do

      begin

       for j:=0 to 25-i do

        for k:=0 to 25-i do

        begin

         sum := i+j+k;

         if sum = 25 then

         begin

          writeln(i:4,j:4,k:4,’ –>’,i:2,’+’ ,j:2,’+',k:2,’ = 25′);

          jumlah:=jumlah+1;

         end;

        end;

      readkey;

      end;

      writeln(’Jumlah Solusi = ‘,jumlah);

end.

 

Comments »

The URI to TrackBack this entry is: http://gudeg.blogsome.com/2007/06/12/program-untuk-menampilkan-semua-solusi-bilangan-bulat-tidak-negative/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com