A regular palindrome is a string of numbers or letters so is the same forward as backward. For example, the string "ABCDEDCBA" was a palindrome because it was the same when the string was read from left to right as W Hen the string is a read from right to left.
A mirrored string is a string for which when each of the elements of the string was changed to its reverse (if it had a rev Erse) and the string is read backwards the result is the same as the original string. For example, the string "3AIAE" was a mirrored string because "a" and "I" are their own reverses, and "3" and "E" were each O Thers ' reverses.
A mirrored palindrome is a string that meets the criteria of a regular palindrome and the criteria of a mirrored string. The string "Atoyota" is a mirrored palindrome because if the string was read backwards, the string is the same as the Origi NAL and because if each of the characters are replaced by it reverse and the result is read backwards, the result is the S Ame as the original string. Of course, "A", "T", "O", and "Y" is all their own reverses.
A List of all valid characters and their reverses are as follows.
Character |
Reverse |
Character |
Reverse |
Character |
Reverse |
A |
A |
M |
M |
Y |
Y |
B |
|
N |
|
Z |
5 |
C |
|
O |
O |
1 |
1 |
D |
|
P |
|
2 |
S |
E |
3 |
Q |
|
3 |
E |
F |
|
R |
|
4 |
|
G |
|
S |
2 |
5 |
Z |
H |
H |
T |
T |
6 |
|
I |
I |
U |
U |
7 |
|
J |
L |
V |
V |
8 |
8 |
K |
|
W |
W |
9 |
|
L |
J |
X |
X |
|
|
Note that O (zero) and 0 (the letter) is considered the same character and therefore only the "0 "is a valid character.
Input Input consists of strings (one per line) each of the which would consist of one to twenty valid characters. There'll be is no invalid characters in any of the strings. Your program should read to the end of file.
Output For each input string, you should print the string starting in column 1 immediately followed by exactly one of the FOLLOWI ng strings.
STRING |
CRITERIA |
"--is not a palindrome." |
If the string is not a palindrome and is not a mirrored string |
"--is a regular palindrome." |
If the string is a palindrome and was not a mirrored string |
"--is a mirrored string." |
If the string is not a palindrome and is a mirrored string |
"--is a mirrored palindrome." |
If the string is a palindrome and is a mirrored string |
Note The output line was to include the-' s and spacing exactly as shown in the table above and demonstrated In the Sample Output below.
In addition, after the output line, you must print a empty line.
Sample Input
Notapalindrome
isapalinilapasi
2a3meas
Atoyota
Sample Output
Notapalindrome--is not a palindrome.
Isapalinilapasi--is a regular palindrome.
2a3meas--is a mirrored string.
Atoyota--is a mirrored palindrome.
Problem: A relatively simple question, LRJ great God code is quite concise ah, but considering the author now compare dishes, unexpectedly msg[m*2+p], this high-end expression, so still use the most traditional four judgment sentence ~
Code
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
using namespace Std;
Char mir[]= "A 3 HIL JM O 2tuvwxy51se Z 8";
Char print[4][55]={"is not a palindrome.", "was a regular palindrome.", "is a mirrored string.", "is a mirrored palindrome."};
int main ()
{
Char ans[1005];
Char mirans[1005];
BOOL flagrev,flagmir;//Two flag, a judgment palindrome, a judgment mirror;
while (~SCANF ("%s", ans))
{
int Len=strlen (ANS);
Flagrev=1;
for (int i=0; i< (len+1)/2; i++)
{
if (Ans[i]!=ans[len-i-1])
{
flagrev=0;
Break
}
}
Flagmir=1;
for (int i=0; i<len; i++)
{
if (Isalpha (Ans[i])) mirans[i]=mir[ans[i]-' A '];//need to be determined here, since numbers and uppercase letters are not contiguous in ASCII;
if (IsDigit (Ans[i])) mirans[i]=mir[ans[i]-' 1 ' +26];
if (Mirans[i]!=ans[len-i-1])
{
flagmir=0;
Break
}
cout<<mirans[i];//This is the statement used to test;
}
cout<<endl;
if (!flagmir&&!flagrev) cout<<ans<< "--" <<print[0]<<endl;
if (!flagmir&&flagrev) cout<<ans<< "--" <<print[1]<<endl;
if (Flagmir&&!flagrev) cout<<ans<< "--" <<print[2]<<endl;
if (Flagmir&&flagrev) cout<<ans<< "--" <<print[3]<<endl;
cout<<endl;
}
return 0;
}
Note: Uvaoj do not want to hdoj that there is a PE this error hint, the author of the output inside of the two minus sign as--and then card for half an hour, blush AH.