多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > UVa 401 Palindromes(鏡像回文字符串)

UVa 401 Palindromes(鏡像回文字符串)

來源:程序員人生   發布時間:2014-09-27 14:53:22 閱讀次數:3583次


題意  給一個字符串 判定其是否為回文串和鏡像串  回文串很好判斷  鏡像串對于每一個字符用數組保存它的鏡像字符就行了  沒有的就是空格

注意若字符串長度為奇數  中間那個字母必須是對稱的才是鏡像串


#include<cstdio> #include<cctype> #include<cstring> const int N = 35; int l; char s[N], mc[] = "A 3 HIL JM O 2TUVWXY5", mn[] = "1SE Z 8 "; bool isRegular() { for (int i = 1; i <= l / 2; ++i) if (s[i] != s[l - i + 1]) return false; return true; } bool isMirrored() { for (int i = 1; i <= (l + 1) / 2 ; ++i) { if (isalpha (s[i]) && s[l - i + 1] != mc[s[i] - 'A']) return false; else if (isdigit (s[i]) && s[l - i + 1] != mn[s[i] - '1']) return false; } return true; } int main() { while (scanf ("%s", s + 1) != EOF) { l = strlen (s + 1); if (isMirrored()) { if (isRegular()) printf ("%s -- is a mirrored palindrome. ", s + 1); else printf ("%s -- is a mirrored string. ", s + 1); } else if (isRegular()) printf ("%s -- is a regular palindrome. ", s + 1); else printf ("%s -- is not a palindrome. ", s + 1); } return 0; }

  Palindromes 

A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.


A mirrored string is a string for which when each of the elements of the string is changed to its reverse (if it has a reverse) and the string is read backwards the result is the same as the original string. For example, the string "3AIAE" is 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 is read backwards, the string is the same as the original and because if each of the characters is replaced by its reverse and the result is read backwards, the result is the same as the original string. Of course, "A""T""O", and "Y" are all their own reverses.


A list of all valid characters and their reverses is 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) are considered the same character and therefore ONLY the letter "0" is a valid character.

Input 

Input consists of strings (one per line) each of which will consist of one to twenty valid characters. There will be 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 following 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 is 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 that the output line is to include the -'s and spacing exactly as shown in the table above and demonstrated in the Sample Output below.

In addition, after each output line, you must print an 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.



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 456在线视频 | 欧美一区二区激情三区 | 欧美一级网 | 一区二区三区中文国产亚洲 | 欧美日韩亚洲精品一区二区 | 日本免费在线 | 国产成人精品免费视频大全五级 | 欧美精品一区二区三区在线 | 久久大香线蕉综合爱 | 久久国产免费福利资源网站 | 91不卡视频 | 久久99久久99精品免观看麻豆 | 色综合亚洲精品激情狠狠 | 日本午夜片成年www 日本午夜三级 | 在线亚洲v日韩v | 久久精品六 | 国产精品视频第一区二区三区 | 大杳蕉伊人狼人久久一本线 | 欧美成人一区二区三区在线视频 | 国产精品精品国产一区二区 | 欧美最猛黑人xxxxx猛交 | 国产成人精品亚洲午夜麻豆 | 欧美一区永久视频免费观看 | 国产在线不卡一区 | 亚洲性生活视频 | 亚洲欧美网站 | 琪琪午夜伦埋大全影院 | 久久久久欧美国产精品 | 中文字幕色站 | 欧美最猛性xxxxx亚洲精品 | 日本一级级特黄特色大片 | 亚洲国产一区二区三区在线观看 | 午夜影院404 | 日本18网站 | 欧美xxxx做受欧美护士 | 欧美日本综合一区二区三区 | 看亚洲色图 | 亚洲视频欧美 | 在线亚洲国产精品区 | 亚洲人成网址在线播放a | 男女视频免费看 |