Some updates.
This commit is contained in:
parent
a0b3856c69
commit
c019a5a884
57 changed files with 2026 additions and 0 deletions
9
2015/2015_03/ada/nauka/cond_structures2/Makefile
Normal file
9
2015/2015_03/ada/nauka/cond_structures2/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
all: hello
|
||||
|
||||
hello: hello.adb
|
||||
gnatmake hello.adb
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f *.ali *.o hello
|
61
2015/2015_03/ada/nauka/cond_structures2/hello.adb
Normal file
61
2015/2015_03/ada/nauka/cond_structures2/hello.adb
Normal file
|
@ -0,0 +1,61 @@
|
|||
with Ada.Text_IO;
|
||||
use Ada.Text_IO;
|
||||
with Ada.Command_Line;
|
||||
use Ada.Command_Line;
|
||||
with Ada.Integer_Text_IO;
|
||||
use Ada.Integer_Text_IO;
|
||||
|
||||
procedure Hello is
|
||||
package IO renames Ada.Text_IO;
|
||||
i: Integer := 2;
|
||||
j: Integer := 1;
|
||||
k: Integer;
|
||||
|
||||
procedure Add (A, B: in Integer; C: out Integer) is
|
||||
begin
|
||||
C := A + B;
|
||||
end Add;
|
||||
|
||||
function Subtract(A, B: Integer) return Integer is
|
||||
begin
|
||||
return A - B;
|
||||
end Subtract;
|
||||
|
||||
function Factorial(X: Integer) return Integer is
|
||||
begin
|
||||
if x <= 1 then
|
||||
return 1;
|
||||
end if;
|
||||
|
||||
return X * Factorial(X-1);
|
||||
end Factorial;
|
||||
|
||||
begin
|
||||
Put_Line("Hello, world");
|
||||
Add(i,j,k);
|
||||
k := Subtract(k,1);
|
||||
case k is
|
||||
when 1 =>
|
||||
Put_Line("i ma wartosc 1");
|
||||
when 2 =>
|
||||
Put_Line("i ma wartosc 2");
|
||||
when 3 =>
|
||||
Put_Line("i ma wartosc 3");
|
||||
when others =>
|
||||
Put_Line("i ma niespotykaną wartość");
|
||||
end case;
|
||||
|
||||
New_Line(1);
|
||||
|
||||
Put("Ala ma ");
|
||||
Put(Factorial(5),0);
|
||||
Put(" kotów");
|
||||
New_Line;
|
||||
|
||||
K := Integer(2.4);
|
||||
|
||||
Put("Skonwertowane 2.5 to: ");
|
||||
Put(K,0);
|
||||
New_Line;
|
||||
|
||||
end Hello;
|
Loading…
Add table
Add a link
Reference in a new issue