Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ConsoleExceptionHandling;
- {$APPTYPE CONSOLE}
- uses
- SysUtils, Crt;
- procedure ExecuteProgram;
- begin
- // Program does something
- raise Exception.Create('Unforeseen exception');
- end;
- function silnia(x:Integer):Comp;
- begin
- if x=0 then
- silnia:=1
- else
- silnia:= silnia(x-1) * x;
- end;
- var n, k:Integer;
- var c:Boolean;
- begin
- try
- c:=false;
- while c=false do
- begin
- while c=false do
- begin
- Write('[in]$ Wpisz n: ');
- ReadLn(n);
- if (n <= 0) or (n>100) then
- WriteLn('[out]$ Blad! ( n powinien nalezec do przedzialu (0, 100> )')
- else
- c:=true;
- end;
- c:=false;
- while c=false do
- begin
- Write('[in]$ Wpisz k: ');
- ReadLn(k);
- if (k<=0) or (k>100) then
- WriteLn('[out]$ Blad! ( k powinno nalezec do przedzialu (0, 100> )')
- else
- c:=true;
- end;
- c:=false;
- if n>=k then
- c:=true
- else
- begin
- ClrScr;
- WriteLn('[out]$ Blad! (k>n)');
- end;
- end;
- WriteLn;
- Write('[out]$ Wartosc symbolu Newtona wynosi: ', (silnia(n) )/ ( silnia(k) * silnia(n-k) ) );
- ReadLn;
- except
- // Handle error condition
- WriteLn('Program terminated due to an exception');
- // Set ExitCode <> 0 to flag error condition (by convention)
- ExitCode := 1;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement