Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://en.wikibooks.org/wiki/Ada_Programming
- type wskaznikdoczegos is access TypT
- := new ...
- kopiowanie plytkie i glebokie
- obj1.all := obj2.all
- -to pierwsze to typ access (wskaznik)
- procedure freevector is new Ada.Unchecked.Deallocation (Object=>Vector, Name =>Vector_Ref);
- ----------
- liczby pseudolosowe
- Ada.Numerics.Discrete_Random;
- Type Rand_Range is range 0..8;
- package Rand_Int is new Discrete_Random(Rand_Range);
- gen: Rand_int.Generator;
- num: Rand_range
- begin Rand_int.reset(gen);
- num: = Rand_int.Random(gen);
- -----------------
- ustalanie pozycji na ekranie
- Ada.Text_IO:
- Set_Line(x);
- Set_Col(y);
- lub
- Biblioteka Screen:
- specjalne sciagi znakow (escpae sequence) ANSI VT 100
- ... tez takie sobie xD
- Biblioteka WIN32_Console z katalogu instalacyjnego AdaCore2015
- trzeba skopiowac pliki do projektu GNAT/2015/share/examples/gnar/knights_tour/src/consoles do swojego katalogu z projektem
- ----------
- wypisywanie na ekranie z losowymi odstępami
- with Ada.Text_IO; use Ada.Text_IO;
- with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
- with Win32_Console; use Win32_Console;
- with Console; use Console;
- with Ada.Numerics.Discrete_Random;
- use Ada.Numerics;
- with Ada.Float_Text_IO; use Ada.Float_Text_IO;
- procedure Main is
- function Generate_Number (MaxValue : Integer) return Integer is
- subtype Random_Type is Integer range 0 .. MaxValue;
- package Random_Pack is new Ada.Numerics.Discrete_Random (Random_Type);
- G : Random_Pack.Generator;
- begin
- Random_Pack.Reset (G);
- return Random_Pack.Random (G);
- end Generate_Number;
- function Generate_Number (MinValue : Integer;
- MaxValue : Integer) return Integer
- is
- subtype Random_Type is Integer range MinValue .. MaxValue;
- package Random_Pack is new Ada.Numerics.Discrete_Random (Random_Type);
- G : Random_Pack.Generator;
- begin
- Random_Pack.Reset (G);
- return Random_Pack.Random (G);
- end Generate_Number;
- task ekran is
- entry print(n,x,y:Integer);
- end ekran;
- task type Zadanie (n,kol:Integer);
- task body Zadanie is
- d: Duration;
- rnd: Integer;
- --a: Integer;
- begin
- Put("xD");
- d:= 0.5;
- -- a:= 0;
- for i in 3..100 loop
- rnd:=Generate_Number(10);
- --a:=a+1;
- d:= Duration(Float(rnd)/(100.0));
- delay d;
- ekran.print(n,i,kol);
- end loop;
- end Zadanie;
- task body ekran is
- loc: Location;
- d: WIN32_Console.Device;
- begin
- Put("xD");
- loop
- accept print(n,x,y:Integer) do
- loc:=(x,y);
- Move_Cursor(d,loc);
- Put("WITAJ" );
- Put(n);
- end print;
- end loop;
- end ekran;
- z1: Zadanie(1,1);
- z2: Zadanie(2,20);
- --e1: ekran;
- begin
- null;
- end Main;
Add Comment
Please, Sign In to add comment