From: James Brewer <firstvestor@gmail.com>
Subject: Re: New to Ada need help implementing Warshall's algorithm
Date: Mon, 26 Sep 2016 10:38:15 -0700 (PDT)
Date: 2016-09-26T10:38:15-07:00 [thread overview]
Message-ID: <80cedca4-c83d-4c40-920c-f3fddb8e1438@googlegroups.com> (raw)
In-Reply-To: <955937c4-b9f9-4e21-9d22-98382df2f45f@googlegroups.com>
Thought I would clarify my previous post. So here it goes.
Ideally, the input data will look like this (the number of row and columns will vary and there will be more than one set (matrix) of data with different row and column names in the input file.
example:
ColName1 ColName2 ColName3 ColNameN
RowName1 0 0 0 0
RowName2 1 1 1 1
RowName3 0 1 0 0
RowNameN 0 1 1 0
Here is the code I have so far without the read from file and output to file implementation.
WITH Text_IO; USE Text_IO; -- This gets the IO facility.
WITH Ada.Integer_Text_IO; USE Ada.Integer_Text_IO; -- This gets the integer IO facility.
--****
-- use zero elements in array to store size 0,0 and row/column names?
-- read size
-- use size to read names of columns
-- store in array
-- use size to read first row of data?
-- as data is read convert from 0/1 to true false and store?
-- if value read = 0 => array2d(n,n) = false
-- if value read = 1 => array2d(n,n) = true
-- * main procedure *
PROCEDURE BooleanTest IS -- Main, but no special name is needed.BEGIN
N : Integer := 4; -- max size ** to be read
OutputConvertion : Integer;
Array2d: ARRAY (1..N, 1..N) OF boolean;
-- * main procedure starts begins*
BEGIN
-- read array size and column names
-- hard coded to be read from file
Array2d(1, 1) := false;
Array2d(1, 2) := false;
Array2d(1, 3) := false;
Array2d(1, 4) := false;
Array2d(2, 1) := false;
Array2d(2, 2) := true;
Array2d(2, 3) := false;
Array2d(2, 4) := true;
Array2d(3, 1) := false;
Array2d(3, 2) := true;
Array2d(3, 3) := false;
Array2d(3, 4) := true;
Array2d(4, 1) := true;
Array2d(4, 2) := false;
Array2d(4, 3) := true;
Array2d(4, 4) := false;
FOR I IN 1..N LOOP
FOR J IN 1..N LOOP
IF Array2d(J,I) = true THEN --true nodes connected
FOR K IN 1..N LOOP
Array2d(J,K) := Array2d(J,K) OR Array2d(I,K);
END LOOP;
END IF;
END LOOP;
END LOOP;
-- *********** output to screen ************
FOR I IN 1..N LOOP
FOR J IN 1..N LOOP
IF Array2d(I,J) = True THEN
OutputConvertion := 1;
ELSE
OutputConvertion := 0;
END IF;
Put( OutputConvertion);
Put(" ");
END LOOP;
New_Line(1);
END LOOP;
END BooleanTest;
-- * main procedure ends *
Thanks again for all the help.
next prev parent reply other threads:[~2016-09-26 17:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 22:05 New to Ada need help implementing Warshall's algorithm James Brewer
2016-09-23 4:31 ` Shark8
2016-09-23 6:26 ` Simon Wright
2016-09-23 15:07 ` James Brewer
2016-09-25 16:06 ` Stephen Leake
2016-09-26 20:40 ` Simon Wright
2016-09-23 14:54 ` James Brewer
2018-02-12 17:45 ` Lucretia
2016-09-26 17:38 ` James Brewer [this message]
2016-09-26 18:29 ` Stephen Leake
2018-02-12 15:36 ` jre11712
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox