Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO; use Ada.Text_IO;
- with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
- procedure Cars is
- ----KONSTANT SOM SÄGER HUR MÅNGA BILAR SOM SKA JÄMFÖRAS----
- C : constant Integer := 5;
- Type Reg_Array is
- array (1..C) of String(1..6);
- Type Weight_Array is
- array (1..C) of Integer;
- Type Trash_Array is
- array (1..C) of String(1..60);
- procedure Get(Reg_Nr : out Reg_Array; Weight : out Weight_Array; Trash : out Trash_Array) is
- Last : Integer;
- begin
- for I in 1..C loop
- Get(Reg_Nr(I));
- Get(Weight(I));
- Get_Line(Trash(I), Last);
- Trash(I)(Last+1 .. Trash'Last) := (others => ' ');
- end loop;
- end Get;
- function Max(Weight : in Weight_Array)
- return Integer is
- Max, Index : Integer := 0;
- begin
- for I in 1..C loop
- if Max < Weight(I) then
- Max := Weight(I);
- Index := I;
- end if;
- end loop;
- Return Index;
- end Max;
- Reg_Nr : Reg_Array;
- Weight : Weight_Array;
- Trash : Trash_Array;
- Index : Integer;
- begin
- Put("Mata in fem bilar: ");
- New_Line;
- Get(Reg_Nr, Weight, Trash);
- Index := Max(Weight);
- New_Line;
- Put("Tyngsta bilen var " );
- Put(Reg_Nr(Index));
- Put(" som väger ");
- Put(Weight(Index),0);
- Put(" kg.");
- end Cars;
Advertisement
Add Comment
Please, Sign In to add comment