first commit
This commit is contained in:
commit
f57dadaeac
10
.#main.adb#
Normal file
10
.#main.adb#
Normal file
@ -0,0 +1,10 @@
|
||||
with ComplexCalculator;
|
||||
with Ada.Text_IO;
|
||||
|
||||
procedure Main is
|
||||
begin
|
||||
-- Your program logic goes here
|
||||
|
||||
-- Example: Display a message
|
||||
Ada.Text_IO.Put_Line("Hello, Ada!");
|
||||
end Main;
|
50
complexcalculator.adb
Normal file
50
complexcalculator.adb
Normal file
@ -0,0 +1,50 @@
|
||||
with Ada.Text_IO;
|
||||
|
||||
package body ComplexCalculator is
|
||||
|
||||
-- Adds two complex numbers
|
||||
function Add(First, Second : ComplexNumber) return ComplexNumber is
|
||||
Result : ComplexNumber;
|
||||
|
||||
begin
|
||||
Result.Real := First.Real + Second.Real;
|
||||
Result.Imaginary := First.Imaginary + Second.Imaginary;
|
||||
return Result;
|
||||
|
||||
end Add;
|
||||
|
||||
-- Subtracts to complex Numbers
|
||||
function Sub(First, Second : ComplexNumber) return ComplexNumber is
|
||||
Result : ComplexNumber;
|
||||
|
||||
begin
|
||||
Result.Real := First.Real - Second.Real;
|
||||
Result.Imaginary := First.Imaginary - Second.Imaginary;
|
||||
return Result;
|
||||
|
||||
end Sub;
|
||||
|
||||
-- Divides two complex numbers
|
||||
function Divide(First, Second : ComplexNumber) return ComplexNumber is
|
||||
Result : ComplexNumber;
|
||||
Bottom : Float; -- improved readability & writability due to it repeating
|
||||
begin
|
||||
Bottom := (First.Real ** 2.0) + (Second.Imaginary ** 2.0);
|
||||
|
||||
Result.Real := ((First.Real * Second.Real) + (First.Imaginary * Second.Imaginary)) / Bottom;
|
||||
Result.Imaginary := ((First.Imaginary * Second.Real) - (First.Real * Second.Imaginary)) / Bottom;
|
||||
return Result;
|
||||
|
||||
end Divide;
|
||||
|
||||
-- Multiply two complex numbers
|
||||
function Multiply(First, Second : ComplexNumber) return ComplexNumber is
|
||||
Result : ComplexNumber;
|
||||
|
||||
begin
|
||||
Result.Real := (First.Real * Second.Real) - (First.Imaginary - Second.Imaginary);
|
||||
Result.Imaginary := (First.Real * Second.Imaginary) + (First.Imaginary * Second.Real);
|
||||
return Result;
|
||||
|
||||
end Multiply;
|
||||
end ComplexCalculator;
|
16
complexcalculator.ads
Normal file
16
complexcalculator.ads
Normal file
@ -0,0 +1,16 @@
|
||||
package ComplexCalculator is
|
||||
-- holds the records and fields for the numbers
|
||||
type ComplexNumber is record
|
||||
|
||||
Real : Float;
|
||||
Imaginary : Float;
|
||||
|
||||
end record;
|
||||
|
||||
-- Defines the functions for calculations.
|
||||
function Add(First, Second : ComplexNumber) return ComplexNumber;
|
||||
function Sub(First, Second : ComplexNumber) return ComplexNumber;
|
||||
function Multiply(First, Second : ComplexNumber) return ComplexNumber;
|
||||
function Divide(First, Second : ComplexNumber) return ComplexNumber;
|
||||
|
||||
end ComplexCalculator;
|
10
main.adb
Normal file
10
main.adb
Normal file
@ -0,0 +1,10 @@
|
||||
with ComplexCalculator;
|
||||
with Ada.Text_IO;
|
||||
|
||||
procedure main is
|
||||
begin
|
||||
-- Your program logic goes here
|
||||
|
||||
-- Example: Display a message
|
||||
Ada.Text_IO.Put_Line("Hello, Ada!");
|
||||
end main;
|
57
main.ali
Normal file
57
main.ali
Normal file
@ -0,0 +1,57 @@
|
||||
V "GNAT Lib v2021"
|
||||
M P W=b
|
||||
A -mtune=generic
|
||||
A -march=x86-64
|
||||
P ZX
|
||||
|
||||
RN
|
||||
RV NO_IO
|
||||
|
||||
U main%b main.adb 6afd184e NE OO SU IL
|
||||
W ada%s ada.ads ada.ali
|
||||
Z ada.strings.text_buffers%s a-sttebu.adb a-sttebu.ali
|
||||
W ada.text_io%s a-textio.adb a-textio.ali
|
||||
W complexcalculator%s complexcalculator.adb complexcalculator.ali
|
||||
|
||||
D ada.ads 20210520051132 76789da1 ada%s
|
||||
D a-except.ads 20210520051128 946f3014 ada.exceptions%s
|
||||
D a-ioexce.ads 20210520051128 e4a01f64 ada.io_exceptions%s
|
||||
D a-stream.ads 20210520051130 119b8fb3 ada.streams%s
|
||||
D a-string.ads 20210520051130 90ac6797 ada.strings%s
|
||||
D a-sttebu.ads 20210520051130 18209c64 ada.strings.text_buffers%s
|
||||
D a-stuten.ads 20210520051130 808c40ad ada.strings.utf_encoding%s
|
||||
D a-tags.ads 20210520051130 9eaa38c6 ada.tags%s
|
||||
D a-textio.ads 20210520051130 aef4d56d ada.text_io%s
|
||||
D a-unccon.ads 20210520051130 0e9b276f ada.unchecked_conversion%s
|
||||
D complexcalculator.ads 20231024191420 1e56cc72 complexcalculator%s
|
||||
D interfac.ads 20210520051132 edec285f interfaces%s
|
||||
D i-cstrea.ads 20210520051132 e53d8b8e interfaces.c_streams%s
|
||||
D main.adb 20231024191028 da5f0151 main%b
|
||||
D system.ads 20210520051136 2ffa5114 system%s
|
||||
D s-crtl.ads 20210520051132 0ebbdb71 system.crtl%s
|
||||
D s-exctab.ads 20210520051132 54135002 system.exception_table%s
|
||||
D s-ficobl.ads 20210520051132 078245e4 system.file_control_block%s
|
||||
D s-parame.ads 20210520051134 4752c4cb system.parameters%s
|
||||
D s-putima.ads 20210520051134 4e095881 system.put_images%s
|
||||
D s-secsta.ads 20210520051134 9b3ab94b system.secondary_stack%s
|
||||
D s-soflin.ads 20210520051134 a7318a92 system.soft_links%s
|
||||
D s-stache.ads 20210520051134 a37c21ec system.stack_checking%s
|
||||
D s-stalib.ads 20210520051134 472fbca8 system.standard_library%s
|
||||
D s-stoele.ads 20210520051134 2dc34a04 system.storage_elements%s
|
||||
D s-stoele.adb 20210520051134 ed88f8fb system.storage_elements%b
|
||||
D s-traent.ads 20210520051134 26a8d361 system.traceback_entries%s
|
||||
D s-unstyp.ads 20210520051134 2b077493 system.unsigned_types%s
|
||||
D s-wchcon.ads 20210520051136 1b7d22d2 system.wch_con%s
|
||||
D unchconv.ads 20210520051136 ca2f9e18 unchecked_conversion%s
|
||||
G a e
|
||||
G c Z b b [main standard 4 11 none]
|
||||
X 1 ada.ads
|
||||
16K9*Ada 20e8 14|2r6 9r4
|
||||
X 9 a-textio.ads
|
||||
58K13*Text_IO 725e16 14|2w10 9r8
|
||||
506U14*Put_Line 14|9s16
|
||||
X 11 complexcalculator.ads
|
||||
1K9*ComplexCalculator 16e22 14|1w6
|
||||
X 14 main.adb
|
||||
4U11*main 4b11 10l5 10t9
|
||||
|
Reference in New Issue
Block a user