Advertisement
katarinaknobel

Komplexa tal

Sep 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.79 KB | None | 0 0
  1. Skriv ett program som läser in två komplexa tal enligt 2 + 3i. Summera dessa och skriv ut, använd underprogram
  2. ex:
  3. Mata in två komplexa tal 2 + 3i 2 - 1i
  4. Summan blev 4 + 2i
  5. Post: Representerar olika typer av data
  6. Re = reella
  7. Im = imaginära
  8. Complex_Type är en record, = en post
  9. ------------------------
  10. with Ada.Text_IO; use Ada.TexT_IO;
  11.  
  12. procedure Komplexa_Tal is;
  13.      type Complex_Type is
  14.           record
  15.              Re: Integer;
  16.              Im: Integer;
  17.  
  18.           end record;
  19.  
  20. ---
  21.  
  22. procedure Get(Talet: out Complex_Type) is
  23.  
  24. C: Character
  25.  
  26. begin
  27. Get(Talet.araccRe);
  28. Get(Talet.Im);
  29. Get(C);
  30.  
  31.      A,B: Complex_Type;
  32.      Sum: Complex_Type;
  33.  
  34. begin
  35. Put("Mata in två komplexa tal ");
  36. Get(A);
  37. Get(B);
  38. Sum:= A+B;
  39. Put("Summan blev: ");
  40. Put(Sum);
  41.  
  42. end Komplexa_Tal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement