0 Replies - 731 Views - Last Post: 10 March 2009 - 01:29 PM Rate Topic: -----

#1 {SNLover87}  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-March 08

Ada help - arrays and palindromes

Posted 10 March 2009 - 01:29 PM

Hi - I've got a problem with a project I'm doing in Ada. Basically the program is supposed to input strings of letters and determine if each string (one per line) is a palindrome as is or a palindrome if each letter of the string is converted to a capital letter. So far I've got my program inputting strings and printing them out as is. My problem is where it processes whether the string is a palindrome or not. I have no idea how to start that. If anyone could possibly point me in the right direction I would GREATLY appreciate it. Thanks.

with ada.text_io; use ada.text_io;

procedure printnstrings2 is
	MaxSize: constant natural := 100;
	Stringsize: CONSTANT Natural := 80;

   TYPE Stringarray IS ARRAY(1 .. Maxsize) OF String(1..Stringsize);

   TYPE intarray is array(1 .. maxsize) of Natural;

	-- Gets ne strings in array a, with their lengths in array la
	procedure getStrings(a: out StringArray; la: out intarray; ne: out Natural) is
		aString: string(1..stringsize);
		len: Natural;
		ne := 0;
		while not end_of_file loop
			get_line(aString, len);
			ne := ne + 1;
			a(ne) := aString;
			la(ne) := len;
		end loop;
	END GetStrings;

	procedure putStrings(a: in StringArray; la: intarray; ne: in Natural) is
		for i in 1 .. ne  loop
			-- Print the string in reverse
			for j in reverse 1 .. la(i) loop
			end loop;
		end loop;
	end putStrings;

	numEntered: Natural;

	thearray: StringArray;
	LenArray: Intarray;


	getStrings(thearray, lenArray, numEntered);
	putStrings(thearray, lenArray, numEntered);

END Printnstrings2;

Is This A Good Question/Topic? 0
  • +

Page 1 of 1