Advertisement
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 Testarrot is
- N: String(1..9999);
- I, NineNine, Skillnad, Summa, L, StringTal, Sista, Forsta, Tal: Integer;
- begin
- Put("Skriv tal: ");
- Get_Line(N, L);
- StringTal := Integer'Value(N(1..L));
- Sista := Integer'Value(N(L..L));
- Forsta := Integer'Value(N(1..1));
- for I in 0..L-2 loop
- NineNine := 9*(10**I) + NineNine;
- end loop;
- if Forsta > Sista then
- Skillnad := Forsta-Sista;
- Put(Skillnad);
- New_Line;
- Summa := Skillnad*NineNine;
- Put(Summa);
- New_Line;
- Tal:= StringTal - Summa;
- Put(Tal);
- end if;
- if Forsta < Sista then
- Skillnad := Sista-Forsta;
- Put(Skillnad);
- New_Line;
- Summa := Skillnad*NineNine;
- Put(Summa);
- New_Line;
- Tal:= StringTal + Summa;
- Put(Tal);
- end if;
- end Testarrot;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement