Lea
eDx, Palindrome
Call WriteString
{ Input integer and determine if a palindrome until 0 entered }
Var AB, BA : Integer; { Numbers
to test if palindromes }
Q :
Integer; { Quotient of division
by 10 }
Begin
Repeat
Writeln('Enter unsigned 16-bit integer:');
Read( AB );
If AB > 0 Then
BEGIN
BA := 0;
Q := AB;
While Q <> 0
Do { Reverse AB to BA }
BEGIN
BA := BA * 10; { Shift BA left 1 digit }
BA := BA + Q Mod 10;{ Right digit of Q = left BA }
Q := Q Div 10; { Drop right digit }
END;
If AB=BA
Then { If
Reversal = Forward }
Writeln('Palindrome') { Then
Palindrome }
Else Writeln('Not
Palindrome');
END;
Until AB = 0;
End.
C++ Algorithm
// Input integer and determine if a palindrome until 0 entered
#include <iostream.h>
void main () {
int AB,
BA; // Numbers to
test if palindromes
int
Q;
// Quotient of division by 10
do {
cout << "Enter unsigned 16-bit
integer:";
cin >> AB;
if (AB > 0) {
BA = 0;
Q = AB;
while ( Q != 0 )
{ // Reverse
AB to BA
BA = BA *
10; //
Shift BA left 1 digit
BA = BA + Q %
10; // Right digit of Q = left
BA
Q = Q /
10;
// Drop right digit
}
if
(AB==BA)
// If Reversal == Forward
cout <<
"Palindrome\n"; // Then Palindrome
else cout << "Not
Palindrome\n";// Else Not Palidrome
}
} while (AB != 0);
}
The
Visual Studio debugger can be used to debug 32-bit Assembler executable programs.
