Programalama > PASCAL

Etiketler: pascal, üçgeni

Ort. 0
Puan ver:
Program PascalTriangle;
uses crt;
{Give your regards to Yaşar Çilek, a wishful thank is enough}
{////////////////////////////////////////}
{This is where factorial is calculated}
function Factorial(n:longint):longint;
var
j,i:longint;
Begin
     j:=1;
     for i:= 1 to n do
     j:=j*i;
     Factorial:=j;
End;
{/////////////////////////////////////}

{//////////////////////////////////////////////////////////}
{This is where magic happens, each number on the table is calculated here,
with a little bit of math info you will recognize it}
function DoCombination(r,d:byte):real;
Begin
	DoCombination:=Factorial(r)/(Factorial(d)*Factorial(r-d))
End;
{/////////////////////////////////////////////////////////////////////////////}


{This is the main program}
var
r:byte;
d:byte;
Begin
     clrscr;
     gotoxy(30,10);
     textcolor(black);
     textbackground(green);
     write('Generating Table Now');
     gotoxy(30,12);
     write('Please Stand By...');
     Delay(5000);
     textcolor(black);
     Textbackground(green);
     clrscr;
     For r:= 0 to 12 do   {Notice that it is only 12 after 12 it just goes crazy}
         Begin            {Probably it is because of factorial function,but this is a simple program}
         for d:=0 to r do
         write(DoCombination(r,d):0:0,' ');
         delay(200);
         Writeln;
         End;
textcolor(black+blink);
writeln('Done');
textcolor(black);
textbackground(green);
gotoxy(25,20);
write('Successfully generated 12 rows!!!');
ReadKey;
End.


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.