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

​   Note that ‘0’ (zero) and ‘O’ (the letter) are considered the same character and therefore ONLY the letter ‘O’ 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.

HINT

regular palindrome 是指输入的字符串和倒序是一样的。

mirrored string 是指将输入的字符船的每一个元素按照要求转换之后的倒序和原来输入的相同。

mirrored palindrome 是指输入的字符串同时满足上面的两个要求。

not a palindrome 什么都不满足。

​   这里采用的思路是将输入的字符串倒序获得一个字符串,然后转换之后再倒序获得一个字符串。然后将输入的字符串和获得的两个字符串比较,按照规则输出结果。

Accepted

#include<stdio.h>
#include<string.h> char reverse[40] = "A 3 HIL JM O 2TUVWXY51SE Z 8 ";//转换规则 int main()
{
char s[22];
while (scanf("%s", s) != EOF)
{
int len = strlen(s);
char backward[22];
for (int i = len-1, k = 0;i >= 0;i--, k++) //获得倒序字符串
{
backward[k] = s[i];
}
backward[len] = '\0';
char revchanged[22];
for (int i = 0;i < len;i++) //获得转换的字符串
{
if (s[i] <= 'Z' && s[i] >= 'A')
revchanged[i] = reverse[s[i] - 'A'];
else
revchanged[i] = reverse[s[i] - '1' + 26]; }
revchanged[len] = '\0';
char revbackchanged[22]; //转换之后获得倒序字符串
for (int i = len-1, k = 0;i >= 0;i--, k++)
revbackchanged[k] = revchanged[i];
revbackchanged[len] = '\0';
if (strcmp(s, backward) == 0 && strcmp(s, revbackchanged) == 0) //结果输出
printf("%s -- is a mirrored palindrome.\n\n", s);
else if (strcmp(s, backward) == 0)
printf("%s -- is a regular palindrome.\n\n", s);
else if (strcmp(s, revbackchanged) == 0)
printf("%s -- is a mirrored string.\n\n", s);
else printf("%s -- is not a palindrome.\n\n", s);
} }

最新文章

  1. MySQL5.6忘记root用户名和密码
  2. 仅个人兴趣,自己通过搜索他人的成果,结合自己的理解,来分析discuz的代码。
  3. 开发ASP.NET MVC设置统一的命名空间
  4. 如何向git账号上提交代码
  5. maven系列之一maven安装和与IDE集成
  6. linux mysql添加用户
  7. [转] JS nodeType返回类型
  8. HDU 4664 Triangulation【博弈论】
  9. Git分支合并选择
  10. Java RandomAccessFile用法 【转】
  11. [HEOI2018] 秘密袭击coat
  12. day11_单元测试_读取yaml文件中的用例,自动获取多个yaml文件内容执行生成报告
  13. TCP连接状态管理
  14. mybaties插件生成代码
  15. Nginx GoAccess安装与配置
  16. 将本地html文件拖到IE8浏览器无法打开,直接弹出一个下载的对话框
  17. Unity3D中录制和输出wav文件
  18. Win10 设置窗口背景色
  19. 解决myeclipse项目中,多出的WebContent文件夹
  20. [转帖] K8S 常用命令

热门文章

  1. 开源OA办公平台搭建教程:基于nginx的快速集群部署——端口分发
  2. Dev GridControl列绑定LookUpEdit数据源:默认值
  3. Vue学习笔记-Vue.js-2.X 学习(三)===&gt;组件化高级
  4. MySQL深入研究--学习总结(1)
  5. 第十届蓝桥杯省赛-试题E: RSA 解密
  6. HDOJ-1160(最长上升子序列变形)
  7. OpenCV计算机视觉学习(13)——图像特征点检测(Harris角点检测,sift算法)
  8. 我与FreeBSD的故事之三
  9. SHA算法摘要处理
  10. 2019HDU多校第七场 HDU6646 A + B = C 【模拟】