题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=6&problem=342&mosmsg=Submission+received+with+ID+12044263

C++代码:

#include <cstdio>
#include <cstring>
int main()
{
char a[3000];
char s[3000];
char str[]={'A','*','*','*','3',
'*','*','H','I','L',
'*','J','M','*','O',
'*','*','*','2','T',
'U','V','W','X','Y',
'5','0','1','S','E','*',
'Z','*','*','8','*'};
while(scanf("%s",a)!=EOF)
{
strcpy(s,a);
int isp=0,ism=0;
int len=strlen(s);
int i,j;
for(i=0,j=len-1;i<=j;++i,--j)
{
if((s[i]=='0'||s[i]=='O')&&(s[j]=='0'||s[j]=='O'))
continue;
else
if(s[i]!=s[j])
break;
}
if(i>j)isp=1;
for(i=0;i<len;++i)
{
if(s[i]>='A'&&s[i]<='Z')
s[i]=str[s[i]-'A'];
else
s[i]=str[s[i]-'0'+26];
}
for(i=0,j=len-1;i<len;++i,--j)
{
if((a[i]=='0'||a[i]=='O')&&(s[j]=='0'||s[j]=='O'))
continue;
else
if(a[i]!=s[j])
break;
}
if(i==len)
ism=1;
if(isp==0&&ism==0)
printf("%s -- is not a palindrome.\n\n",a);
else
if(isp==1&&ism==0)
printf("%s -- is a regular palindrome.\n\n",a);
else
if(isp==0&&ism==1)
printf("%s -- is a mirrored string.\n\n",a);
else
printf("%s -- is a mirrored palindrome.\n\n",a);
}
return 0; }

UVa-Palindromes的更多相关文章

  1. UVA - 11584 Partitioning by Palindromes[序列DP]

    UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...

  2. UVA 11584 一 Partitioning by Palindromes

    Partitioning by Palindromes Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %l ...

  3. UVa 353 - Pesky Palindromes

    称号:字符串统计回文子的数量. 分析:dp,暴力.因为数据是小,直接暴力可以解决. 说明:(UVa最终评出800该). #include <iostream> #include <c ...

  4. uva 11584 Partitioning by Palindromes 线性dp

    // uva 11584 Partitioning by Palindromes 线性dp // // 题目意思是将一个字符串划分成尽量少的回文串 // // f[i]表示前i个字符能化成最少的回文串 ...

  5. 区间DP UVA 11584 Partitioning by Palindromes

    题目传送门 /* 题意:给一个字符串,划分成尽量少的回文串 区间DP:状态转移方程:dp[i] = min (dp[i], dp[j-1] + 1); dp[i] 表示前i个字符划分的最少回文串, 如 ...

  6. uva 401.Palindromes

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  7. UVA 11584 Partitioning by Palindromes (字符串区间dp)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  8. 【UVa】Partitioning by Palindromes(dp)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=27&page=sh ...

  9. UVa 11584 - Partitioning by Palindromes(线性DP + 预处理)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  10. uva 401 Palindromes 解题报告

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

随机推荐

  1. android怎样实现自动点击功能

    一个按钮之类的控件的自动点击的话,可以定时调用 button.performClick();

  2. on、where、having的区别(转载)

    on.where.having的区别 on.where.having这三个都可以加条件的子句中,on是最先执行,where次之,having最后.有时候如果这先后顺序不影响中间结果的话,那最终结果是相 ...

  3. Spring3表达式语言(SpEL)学习笔记

    最新地址请访问:http://leeyee.github.io/blog/2011/06/19/spring-expression-language Spring Excpression Langua ...

  4. 在webx.ml中 配置struts2 后 welcome-file-list 失效的解决办法

    struts2 <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.a ...

  5. Android 高仿 频道管理----网易、今日头条、腾讯视频 (可以拖动的GridView)附源码DEMO

    距离上次发布(android高仿系列)今日头条 --新闻阅读器 (二) 相关的内容已经半个月了,最近利用空闲时间,把今日头条客户端完善了下.完善的功能一个一个全部实现后,就放整个源码.开发的进度就是按 ...

  6. Incompatible namespaceIDs或连接被对端重置异常的解决

    Workaround 1: Start from scratch I can testify that the following steps solve this error, but the si ...

  7. JS、JQury - 文本框内容改变事件

    例子: 效果: 前端代码: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="De ...

  8. Selenium webdriver 常见问题

    出现java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal 是因为缺少 xml jar ,如果使用的是maven 可以依赖 <d ...

  9. jquery动态改变背景颜色插件

    GETHUB下载地址 背景颜色用animate方法时时无法改变颜色的 所以要使用插件进行补充. 用法: <!DOCTYPE html> <html> <head> ...

  10. 【C语言天天练(十五)】字符串输入函数fgets、gets和scanf

    引言:假设想把一个字符串读到程序中.必须首先预留存储字符串的空间.然后使用输入函数来获取这个字符串. 读取字符串输入的第一件事是建立一个空间以存放读入的字符串. char *name; scanf(& ...