Sabtu, 06 November 2010

contoh repetisi dalam free pascal

uses crt;
var a,b,c,d,e,i,j:integer;
begin
        CLRSCR;
        write('masukkan angka:');readln(a);
        writeln;
        b:=a-1 ; c:=1;
        for i:= 1 to a do

        begin
                for j:=1 to b do
                begin
                write(' ');
                end;

                for j:=1 to c do
                begin
                write('*');
                end;
                writeln;
                b:=b-1;c:=c+2;
        end;
        d:=1;e:=c-4;
        for i:= 1 to a-1 do
        begin
                for j:= 1 to d do
                begin
                write(' ');
                end;
                for j:= 1 to e do
                begin
                write('*');
                end;
                writeln;
                d:=d+1; e:=e-2;
        end;




readkey;
end.


hasil :
     *
   ***
  *****
*******
  *****
    ***
      *

Tidak ada komentar:

Poskan Komentar