【例题3-3 UVA - 401】Palindromes
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
如果一个字符没有对应的镜像,那么它对应的是一个空格。
然后注意
aba这种情况。
这种情况下b也要查一下它的镜像是不是和b一样。
【错的次数】
在这里输入错的次数
【反思】
在这里输入反思
【代码】
#include <bits/stdc++.h>
using namespace std;
const char * rev = {"A 3 HIL JM O 2TUVWXY51SE Z 8 "};
const char * msg[] = {"is not a palindrome.","is a regular palindrome.",
"is a mirrored string.","is a mirrored palindrome."};
const int N = 100;
char s[N];
char re(char ch)
{
if (isalpha(ch))
return rev[ch-'A'];
return rev[ch-'0'+25];
}
int main()
{
//freopen("F:\\rush.txt","r",stdin);
while (~scanf("%s",s))
{
int len = strlen(s);
int x = 1,y = 1;
for (int i = 0;i < (len+1)/2;i++)
{
if (s[i]!=s[len-i-1]) x = 0;
if (re(s[i])!=s[len-i-1]) y = 0;
}
printf("%s -- %s\n\n",s,msg[y*2+x]);
}
return 0;
}
【例题3-3 UVA - 401】Palindromes的更多相关文章
- uva 401.Palindromes
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- uva 401 Palindromes 解题报告
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 401 Palindromes(镜像回文字符串)
题意 给一个字符串 判定其是否为回文串和镜像串 回文串非常好推断 镜像串对于每个字符用数组保存它的镜像字符即可了 没有的就是空格 注意若字符串长度为奇数 中间那个字母必须是对称的才是镜 ...
- UVa 401 - Palindromes 解题报告 - C语言
1.题目大意 输入字符串,判断其是否为回文串或镜像串.其中,输入的字符串中不含0,且全为合法字符.以下为所有的合法字符及其镜像: 2.思路 (1)考虑使用常量数组而不是if或switch来实现对镜像的 ...
- Palindromes UVA - 401
A regular palindrome is a string of numbers or letters that is the same forward as backward. For e ...
- UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494
白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...
- 401 Palindromes(回文词)
Palindromes A regular palindrome is a string of numbers or letters that is the same forward as ba ...
- 【UVA 401】BUPT 2015 newbie practice #2 div2-B-Palindromes
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102419#problem/B A regular palindrome is a str ...
- 【鬼畜】UVA - 401每日一题·猛男就是要暴力打表
管他什么rev数组,msg数组简化代码 #define _CRT_SECURE_NO_WARNINGS #include <cmath> #include <iostream> ...
随机推荐
- 搭建 Nginx 静态网站
示例代码:/etc/nginx/nginx.conf user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid / ...
- deep-in-es6(四)
不定参数和默认参数: function containsAll(str) { for(var i = 1;i < arguments.length;i++) { var hasStr = arg ...
- windows安装memcached
http://www.cnblogs.com/wujuntian/p/4791220.html
- C# WinForm设置透明
1:通过设置窗体的 TransparencyKey实现 例:窗体中的白色会变成透明 this.BackColor =Color.White; this.TransparencyKey = ...
- HDOJ 5399 Too Simple
每个函数都必须是一个排列,经过连续的一段确定函数后数字不能少. 满足上面的条件的话,仅仅要有一个-1函数特别的排列一下就能够满足要求,剩下的能够任意填 没有-1的话特判 Too Simple Time ...
- c# 查询sql 返回多个參数
1.依据须要查询mysql 语句,返回三个须要的參数,不是数据集 2.编写函数例如以下: public static void GetParas(string 条件1, out string 返回值1 ...
- BASH 文本模版的简单实现 micro_template_compile
详细代码 ############################### # # Funciton: micro_template_compile # # Parameter: # [1] => ...
- <memory>(包括了auto_ptr,shared_ptr等各种指针)
Memory elements This header defines general utilities to manage dynamic memory: Allocators allocator ...
- sqlserver存储过程实现多表分页
if @PageIndex = 1 begin if @strWhere != ’’ set @strSQL = ’select top ’ + str(@PageSize) +’ ’+@strGet ...
- vue.js最最最最简单实例
vue.js最最最最简单实例 一.总结 一句话总结: 1.vue.js实现实现数据的双向绑定用的是什么标记? 双大括号:比如{{message}} 2.vue数据循环输出的标记是什么? 用的是标签的v ...