[UVa] Palindromes (401)

Source: Internet
Author: User

Uva-401palindromes
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

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 The left-to-right as-is-string is-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" are each others ' 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 original and because if each of the characters are replaced by their reverse and the result is read backwards, th E result is the same 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

Atoyota

Sample Output

Atoyota--is a mirrored palindrome.

Hint

Use the C + + 's class of string would be convenient, but not a must

AC Code:

#include <cstdio>#include<cstring>#include<cctype>#defineMAX 30//Maximum character lengthConst Char* Rev ="A 3 HIL JM O 2tuvwxy51se Z 8";//the mirror character used to store the corresponding letter, if it is not indicated with ' 'Const Char* msg[] = {"is not a palindrome.","Is a regular palindrome.","is a mirrored string.","Is a mirrored palindrome."};//used to hold the message string to be emittedCharRCharR) {    /*This function returns the mirror character of the corresponding character if the character is a number, its mirror character is 0 to 25 in the Rev array if the character is a number, its mirror character is 26 to the last*/    if(Isalpha (R))returnRev[r-'A']; Else returnRev[r-'0'+ -];}intMain () {CharStr[max];  while(SCANF ("%s", str) = =1) {//does not contain whitespace characters, can be entered directly with scanf, SCANF returns the number of data read in Fu Chenggong by the format control        intLen =strlen (str); intp =1, M =1;  for(inti =0; I < (len +1) /2; i++){            if(Str[i]! = Str[len-1-i]) p =0;//at this time str is not a palindrome string, the output information is msg in the 0,2            if(R (str[i])! = Str[len-1-i]) m =0;//at this time STR is not a mirror string, the output content is msg 0, 2} printf ("%s--%s\n\n", str, msg[m *2+p]); }     return 0;} 

Submitted three times before the past, is in the confirmation loop end there is a problem ah, should be (len + 1)/2, written len/2. This is really:)

[UVa] Palindromes (401)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.