fork download
  1. {$APPTYPE CONSOLE}
  2. Program Kalkulator;
  3. Uses SysUtils;
  4.  
  5. Function GetInput(Title: String): Integer;
  6. Var Temp: String;
  7. Out : Integer;
  8. Begin
  9. Write(Title+' ');
  10. Readln(Temp);
  11. if (not TryStrToInt(Temp, Out)) Then
  12. Begin
  13. Writeln('', Title, ''' nie jest liczba!');
  14. Readln;
  15. Halt;
  16. End;
  17. GetInput := Out;
  18. End;
  19.  
  20. Procedure Dodawanie(A, B: Integer); pascal;
  21. Begin
  22. Writeln;
  23. Writeln(A,'+',B,'=',A+B);
  24. End;
  25.  
  26. Procedure Odejmowanie(A, B: Integer); pascal;
  27. Begin
  28. Writeln;
  29. Writeln(A,'-',B,'=',A-B);
  30. End;
  31.  
  32. Procedure Dzielenie(A, B: Integer); pascal;
  33. Begin
  34. Writeln;
  35. Writeln(A,'/',B,'=',A/B:6:4,' (reszta ',A mod B,')');
  36. End;
  37.  
  38. Procedure Mnozenie(A, B: Integer); pascal;
  39. Begin
  40. Writeln;
  41. Writeln(A,'*',B,'=',A*B);
  42. End;
  43.  
  44. Procedure Pierwiastek(A: Integer); pascal;
  45. Begin
  46. Writeln;
  47. Writeln('sqrt(',A,')=',sqrt(A):6:4);
  48. End;
  49.  
  50. Procedure Potega(A, B: Integer); pascal;
  51. Function Power(iBase, iExponent: Integer): Extended;
  52. Begin
  53. Power := Exp(Ln(iBase) * iExponent);
  54. End;
  55. Begin
  56. Writeln;
  57. Writeln(A,'^',B,'=',round(Power(A, B)));
  58. End;
  59.  
  60. Procedure Silnia(A: Integer); pascal;
  61. Var Res, I: Integer;
  62. Begin
  63. Res := 1;
  64. For I := 1 To A Do
  65. Res := Res*I;
  66. Writeln;
  67. Writeln(A,'!=',Res);
  68. End;
  69.  
  70. Procedure MainMenu;
  71. Const Opcje: Array[0..7] of String = ('dodawanie', 'odejmowanie', 'dzielenie', 'mnozenie', 'pierwiastek', 'potega', 'silnia', 'wyjscie');
  72. Var Opcja: String;
  73. I, Op: Integer;
  74. Begin
  75. Op := -1;
  76. Repeat
  77. Writeln;
  78. Write('Podaj nazwe dzialania do wykonania: ');
  79. Readln(Opcja);
  80. Opcja := LowerCase(Opcja);
  81. For I := Low(Opcje) To High(Opcje) Do
  82. if (Opcja = Opcje[I]) Then
  83. Op := I;
  84. Until (Op >= 0);
  85. Case Op Of
  86. 0: Dodawanie(GetInput('Podaj skladnik:'), GetInput('Podaj skladnik:'));
  87. 1: Odejmowanie(GetInput('Podaj odjemna:'), GetInput('Podaj odjemnik:'));
  88. 2: Dzielenie(GetInput('Podaj dzielna:'), GetInput('Podaj dzielnik:'));
  89. 3: Mnozenie(GetInput('Podaj czynnik:'), GetInput('Podaj czynnik:'));
  90. 4: Pierwiastek(GetInput('Podaj liczbe:'));
  91. 5: Potega(GetInput('Podaj podstawe:'), GetInput('Podaj wykladnik:'));
  92. 6: Silnia(GetInput('Podaj liczbe:'));
  93. 7: Halt;
  94. End;
  95. MainMenu;
  96. End;
  97. Begin
  98. Writeln('--------------');
  99. Writeln('- Kalkulator -');
  100. Writeln('--------------');
  101. Writeln;
  102. Writeln('Dostepne funkcje:');
  103. Writeln;
  104. Writeln('dodawanie, odejmowanie, dzielenie, mnozenie, pierwiastek, potega, silnia,wyjscie');
  105. Writeln;
  106. MainMenu;
  107. End.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Free Pascal Compiler version 2.2.0 [2009/11/16] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling prog.pas
prog.pas(1,2) Warning: APPTYPE is not supported by the target OS
prog.pas(11,31) Error: Call by var for arg no. 2 has to match exactly: Got "SmallInt" expected "LongInt"
prog.pas(17,17) Warning: Local variable "Out" does not seem to be initialized
prog.pas(107,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
stdout
Standard output is empty