Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. with Ada.Text_IO; use Ada.Text_IO;
  2. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  3.  
  4. procedure Testarrot is
  5.  
  6. N: String(1..9999);
  7. I, NineNine, Skillnad, Summa, L, StringTal, Sista, Forsta, Tal: Integer;
  8.  
  9. begin
  10. Put("Skriv tal: ");
  11. Get_Line(N, L);
  12.  
  13. StringTal := Integer'Value(N(1..L));
  14. Sista := Integer'Value(N(L..L));
  15. Forsta := Integer'Value(N(1..1));
  16. for I in 0..L-2 loop
  17. NineNine := 9*(10**I) + NineNine;
  18. end loop;
  19.  
  20.  
  21.  
  22.  
  23. if Forsta > Sista then
  24. Skillnad := Forsta-Sista;
  25. Put(Skillnad);
  26. New_Line;
  27. Summa := Skillnad*NineNine;
  28. Put(Summa);
  29. New_Line;
  30. Tal:= StringTal - Summa;
  31. Put(Tal);
  32. end if;
  33.  
  34. if Forsta < Sista then
  35. Skillnad := Sista-Forsta;
  36. Put(Skillnad);
  37. New_Line;
  38. Summa := Skillnad*NineNine;
  39. Put(Summa);
  40. New_Line;
  41. Tal:= StringTal + Summa;
  42. Put(Tal);
  43. end if;
  44.  
  45.  
  46.  
  47. end Testarrot;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement