|
From: Ioannis V. <no...@ya...> - 2002-03-09 15:32:02
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of chromatonus 712 > Sent: Saturday, March 09, 2002 4:10 AM > To: dev...@li... > Subject: [Dev-C++] palindrome base prgm >=20 >=20 >=20 > hi, I am writing a prgm that takes a number (like 19), and=20 > its base, (10 in=20 > this case), and perform the following operation until a palindrome is=20 > obtained: >=20 > add the reverse of 19 > 19+91 =3D 110 > add the reverse of 110 > 110 + 11 =3D 121....a palindrome, > and the prgm should print out the 121. >=20 > I think there are several caveats: > bases can range from 10 to 16, so the A,B,C,D,E,F is tricky=20 > to handle as=20 > numbers, because the input would be like A32 for example. > And how to reverse the number and check to see if it's a=20 > palindrome, and=20 > also doing addition in different bases. Any tip on these will=20 > be greatly=20 > appreciated! Get the number as a string, check it and reverse it and then convert it to number. I am still studying C++ so i do not know if it provides some else string to number facility, i so for the conversion i should suggest sscanf() on string::c_str(). Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.d2g.com * Alternative URL: http://run.to/noicys |