Palindromes UVa401 字符串

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情
Root :: Problem Set Volumes :: Volume IV     

401 - Palindromes 回文词

我头一回在UVa上写题啊,不知道怎么迅速查询题目。暂时先用这样的格式来标记题目吧。

用字符常量数组来标记镜面字母比较方便啊,这一题提交了4次~  -.-  2次编译错误。 UVa还真是娇气啊。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
using namespace std;
#define LEN 25
char s[LEN];
char self[]="123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char rev[]="1SE*Z**8********A***3**HIL*JM*O***2TUVWXY5";

int main(){
#ifndef ONLINE_JUDGE
	freopen("401in.txt","r",stdin);
#endif
	bool pali_flag,mirror_flag;
	int i,j;
	while (scanf("%s",s)!=EOF){
		pali_flag=true;
		mirror_flag=true;
		for (i=0,j=strlen(s)-1;i<=j;i++,j--){
			if (!pali_flag&&!mirror_flag)
				break;
			if (s[i]!=s[j])
				pali_flag=false;
			if (self[s[i]-49]!=rev[s[j]-49])
				mirror_flag=false;
		}
		if (!pali_flag&&!mirror_flag)
			printf("%s -- is not a palindrome.\n",s);
		else if (pali_flag&&!mirror_flag)
			printf("%s -- is a regular palindrome.\n",s);
		else if (!pali_flag&&mirror_flag)
			printf("%s -- is a mirrored string.\n",s);
		else if (pali_flag&&mirror_flag)
			printf("%s -- is a mirrored palindrome.\n",s);
		cout<<endl;
	}
	return 0;
}


UVA401 ​​​​​​​Palindromes字符串 Palindromes  UVA - 401  题目传送门 题目大意:给你一个字符串,判断其是回文串还是镜像串。 AC代码: #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cmath&gt; #include &lt;cstdlib&gt; #inclu... 阅读详情

相关推荐

uva 401 Palindromes字符串处理)

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

不慌不忙、不急不躁 1703

uva401 Palindromes 字符串,模拟

没什么难度,但是网上的代码都比较冗长,我模仿刘汝佳写的,这才叫编程之美啊。 ps:输出间空一行,别忘了 #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;

萌即正义的萌新教学 477

UVa 401 Palindromes(简单字符串

简单的判断是否是回文串、镜像串,然后自己写的真费劲,没逃掉刘汝佳的书,这里的代码很有技巧性,特别值得学习,额,其实他书上的代码都很精简 Character Reverse Character Reverse Character Reverse A A M M Y Y B   N   Z 5 C   O O

huatian5的博客 1961

UVA - 401-Palindromes

题目链接:Palindromes UVA - 401 Palindromes Time Limit:3000MS   Memory Limit:Unknown   64bit IO Format:%lld & %llu SubmitStatus Description A regular palindrome is a

Never say never 862

UVa 401 - Palindromes

这题是Rujia Liu推荐的第一个字符串题。 题意很容易看懂,就是给出字符串,判断其是否是回文或镜面对称回文。输出有4种情况,给出的表格做了很清楚的说明。 思路:写两个函数,is_palindrome()判断是否是回文串,is_mirrored()判断是否是镜像对称串。

程书画的 BLOG 4770

UVA 401 Palindromes 字符串

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

kdwycz的刷题空间 829

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

 题意  给一个字符串 判定其是否为回文串和镜像串  回文串很好判断  镜像串对于每一个字符用数组保存它的镜像字符就行了  没有的就是空格 注意若字符串长度为奇数  中间那个字母必须是对称的才是镜像串 #include #include #include const int N = 35; int l; char s[N], mc[] = "A 3 HIL JM O

Deng's site \# 1560

UVA401 Palindromes字符串处理】

输入一个字符串,判断它是否为回文串以及镜像串。输入字符串保证不含数字0。所谓回文串,就是反转以后和原串相同,如abba和madam。所谓镜像串,就是左右镜像之后和原串相同,如2S和3AIAE。注意,并不是每个字符在镜像之后都能得到一个合法字符。在本题中,每个字符的镜像如图3-3所示(空白项表示该字符镜像后不能得到一个合法字符)。 输入的每行包含一个字符串(保证只有上述字符。不含空白字符),判断它是...

逐梦者 309

UVa OJ 401-Palindromes

<br />简单字符串处理:<br />{ Author:wzx961008 Problem:UVa 401-Palindromes Verdict:Accepted Language:PASCAL Run Time:0.024s Submission Date:2011-01-12 01:05:27 } const mirrorchar1:string='ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'; mirrorchar2:strin

Chiwin 538

UVA 401 - Palindromes字符串

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

coco430的专栏 508

Palindromes - UVa 401 字符串处理

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 stri

提比的强行AC 958

uva 401 Palindromes //字符串

Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA"

天道酬勤 814

UVa 401 Palindromes (字符串匹配)

401 - Palindromes Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=342 A regular palindrome is a string of nu

AC,∑ndless 1374

UVa 401 Palindromes 字符串基础

题目链接:http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=19520 题目大意:给你一个字符串,一要你判断是否是回文串;二要把这个字符串的每一个字符按照给定的规则翻转,而然后判断翻转后的字符串是否是原串的逆序。 思路不难,但是有些地方要注意。首先要注意的一个问题是,大写字母O和数字0是一样的。这一点我觉得题...

Jianquan520的专栏 209

UVa401_Palindromes(小白书字符串专题)

Description   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

_nplus 1102

UVA-401 Palindromes

2016-07-12 UVA - 401 Palindromes 题目大意:判断是否回文、镜面。回文即从左往右与从右往左相同。镜面根据所提供的表格,可能存在非法字符。一开始理解错题意,以为不存在非法字符就是镜面,实际上是从左往右根据表格将全部字符化为镜像后,要与从右往左相同。 解题思路:遍历每个元素,进行回文的判断,是回文的话tag[0] = 1 ,不是的话tag[0]

振丿Love 383

uva 401Palindromes)(回文字符串

(1)镜面、回文字符串判定,简单的字符串问题,uva上的第一交,AC。 (2)开数组记录较为凌乱的数据,常用的手段。 具体代码: View Code #include<stdio.h> #include<string.h> char map1[]="ABCD EFG HIJK LMN PQR STUVWXYZ1234 567 89 "; ch...

weixin_30246221的博客 102

UVa 401 Palindromes(字符串,回文)

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 t

Good morning,good afternoon and good night 1121

uva 401 Palindromes(基本的字符串处理)

这个题目不难,就是基本的字符串处理,涉及到一个回文字符串跟一个镜像串。一次判断即可。 对于镜像串我这里用的是map。。用的是键-值的一一对应关系。 不解的是莫名的wrong 了好几次。。。最后又莫名的过了,。。 好神奇。。 下面是过了的代码。。 #include #include #include #include #include using namespace std; map

多啦A梦也会有好多的烦恼 836
上一篇: 最大报销额 hdu1864 01背包
下一篇: Excuses, Excuses! UVa409 字符串
花酱_
博客等级 码龄14年 30粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值