UVa 401 - Palindromes
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;char aa[4][40]={" -- is not a palindrome."," -- is a regular palindrome."," -- is a mirrored string."," -- is a mirrored palindrome."};char bb[40]={'A','0','0','0','3','0','0','H','I','L','0','J','M','0','O',
'0','0','0','2','T','U','V','W','X','Y','5','1','S','E','0','Z','0','0','8','0'};bool palindome(string);
bool mirrored(string);int main()
{// freopen("input.txt","r",stdin);string s;bool f1,f2;int i;while(cin>>s){f1=palindome(s);f2=mirrored(s);if(!f1&&(!f2))cout<<s<<aa[0]<<endl;else if(f1&&!f2)cout<<s<<aa[1]<<endl;else if(!f1&&f2)cout<<s<<aa[2]<<endl;elsecout<<s<<aa[3]<<endl;cout<<endl;}return 0;}bool palindome(string s)
{int i,len;len=s.length();for(i=0;i<len/2;i++)if(s[i]!=s[len-i-1])return false;return true;}bool mirrored(string s)
{int i,len,j=0;string s1;len=s.length();for(i=0;i<s.length();i++){ if(s[i]>='A'&&s[i]<='Z'){if(bb[s[i]-'A']=='0')return false;s1[i]=bb[s[i]-'A'];}else{if(bb[s[i]-'0'+25]=='0')return false;s1[i]=bb[s[i]-'0'+25];}}for(j=0;j<s.length();j++)if(s[j]!=s1[--i])return false;return true;
}
转载于:https://www.cnblogs.com/aiheshan/p/8854254.html
UVa 401 - Palindromes相关推荐
- uva 401.Palindromes
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- UVaOJ 401 Palindromes
原题: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page ...
- 【鬼畜】UVA - 401每日一题·猛男就是要暴力打表
管他什么rev数组,msg数组简化代码 #define _CRT_SECURE_NO_WARNINGS #include <cmath> #include <iostream> ...
- 紫书《算法竞赛入门经典》
紫书<算法竞赛入门经典>题目一览 第3章 数组和字符串(例题) UVA 272 TEX Quotes UVA 10082 WERTYU UVA 401 Palindromes UVA 34 ...
- SUPERBIN技术周刊第6期
本技术周刊是以周为单位作为里程碑,记录一个程序员视角下的所见,所学,所想.兴趣领域包括:数学,算法,图形,图像,音视频,AI,游戏,软件开发技术,操作系统,开源,以及生活杂记等."不积跬步, ...
- UVA401 Palindromes【字符串】
Palindromes UVA - 401 题目传送门 题目大意:给你一个字符串,判断其是回文串还是镜像串. AC代码: #include <cstdio> #include <io ...
- 提取了下刘汝佳推荐的题号...
今天闲来没事上uva oj提取了下刘汝佳推荐的acm题号,原始数据如下: Volume 0. Getting Started 10055 - Hashmat the Brave Warrior ...
- 《算法竞赛入门经典》Chap3
<算法竞赛入门经典(第二版)>第三章 思考题 题目1 必要的存储量 题目2 统计字符1的个数 示例程序 程序3-1 逆序输出 程序3-2 开灯问题 程序3-3 蛇形填数 程序3-4 竖式问 ...
- 初学者acm的练习题指南
上机练习题参考题 忘了在哪找的啦~~希望对大家有帮助呦 <!--[if !supportLists]-->1. <!--[endif]-->Programming Bas ...
最新文章
- yum源的超级简单配置
- 迭代器报“vector iterators incompatible”错的几种可能
- linux编译项目的命令,Linux用make指令编译进度条程序
- 使用SharePoint Server 2007搜索对象模型编程创建搜索查询
- activity的启动窗口
- Algs4-2.1.17动画-插入排序
- python的序列化是什么意思_python 什么是对象序列化
- 用jquery + iframe實現iframe子頁面加載完前的緩沖效果
- ICLR2019 论文清单
- django-验证码
- 优秀PPT 设计的十大秘诀
- 关于网站速度优化的一点建议
- hp 交换机远程连接_Hp服务器 iLO3 使用方法
- dym 微服务 快速开发框架
- 30行js爬取顶点全网任意小说
- 游戏:杀戮尖塔(Slay the spire)mod--拉格朗·月
- 使用Telnet 命令行发信
- 做外贸十大不能接的订单!
- 马来西亚吉隆坡召开的2010OpenWebAsia大会
- Windows XP 源代码在线泄露