comp.lang.ada
 help / color / mirror / Atom feed
From: Will <willmann817@gmail.com>
Subject: Re: Ada95 Help 2D arrays
Date: Fri, 20 Apr 2012 10:33:57 -0700 (PDT)
Date: 2012-04-20T10:33:57-07:00	[thread overview]
Message-ID: <5774709.1285.1334943237337.JavaMail.geo-discussion-forums@vbbfk16> (raw)
In-Reply-To: <31137140.191.1334922395977.JavaMail.geo-discussion-forums@ynjb15>

Here is my solution and no doubt it does work!  

type Int_Array is array(Positive range <>) of Integer;
   type Int_Matrix is array(Positive range <>, Positive range <>) of Integer;
	

   function Best_Combined_Score(Grid : Int_Matrix) return Integer is  
   Total : integer := 0;
	RowTotal : integer := 0;
	ColumnTotal : integer :=0;
	Sum : Integer := 0;
	begin	 
	
	   
	
	for R in Grid'Range(1)loop
	RowTotal := 0;
		for C in Grid'Range(2) loop
			Rowtotal := Rowtotal +Grid(R,C);
		end loop;
		
	for Column in Grid'Range(2) loop
	ColumnTotal := 0;
		for Row in Grid'Range(1)loop
	 	ColumnTotal := ColumnTotal + Grid(Row,Column);      
	   end loop;                                          
		                                                 		
	Total := RowTotal + ColumnTotal - Grid(R, Column);
		
		if Total > Sum then 
		 Sum := Total;
		end if;
		
		end loop;
		end loop;
		
		
     return Sum;
   end Best_Combined_Score;



  parent reply	other threads:[~2012-04-20 17:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 11:46 Ada95 Help 2D arrays Will
2012-04-20 16:27 ` Niklas Holsti
2012-04-20 16:55 ` Will
2012-04-20 17:33 ` Will [this message]
2012-04-20 18:12   ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox