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; begin 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 BEGIN for i in 1 .. ne loop Put(A(I)(1..La(I))); new_line; -- Print the string in reverse for j in reverse 1 .. la(i) loop put(a(i)(j)); end loop; new_line; end loop; end putStrings; numEntered: Natural; thearray: StringArray; LenArray: Intarray; begin getStrings(thearray, lenArray, numEntered); putStrings(thearray, lenArray, numEntered); END Printnstrings2;
Page 1 of 1
0 Replies - 670 Views - Last Post: 10 March 2009 - 01:29 PM
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.
Page 1 of 1