日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當前位置:首頁 > 互聯(lián)網(wǎng) > UVa 401 Palindromes(鏡像回文字符串)

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

來源:程序員人生   發(fā)布時間:2014-09-27 14:53:22 閱讀次數(shù):3592次


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

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


#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.



生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 精品一区二区精品 | 麻豆视频国产 | 国产精品区一区二区三含羞草 | 人人爽视频 | 久久久久久久一区二区 | 久在线视频 | 精品国产一区二区三区日日嗨 | 717影视三级理论电影在线 | 国产福利网站 | 福利视频自拍偷拍 | www网站在线观看 | 三级毛片视频 | 亚洲精品观看 | 久久国产精品免费一区二区三区 | 插插插插综合 | 欧美亚洲综合网 | 69xx×在线观看| 亚洲欧美日韩中文视频 | www黄色| 亚洲精品国产区欧美区在线 | 欧洲亚洲女同hd | 成人欧美一区二区三区视频网页 | 国产农村1级毛片 | 欧美xxxhd | 91久久精品国产 | 国产高清久久久 | 国产传媒一区二区三区 | 日本毛片在线观看 | 日韩不卡 | 精品无码久久久久久国产 | 91亚洲国产成人久久精品网站 | 国产在线网站 | 国产精品一区二区在线观看 | 亚洲综合影院 | 精品美女在线视频 | 国产精品99久久久久久动医院 | 99久久夜色精品国产亚洲96 | 日本久久精品 | 久久视频国产 | 亚洲一区二区三区四区视频 | 亚洲福利片 |