南邮 OJ 1384 Palindromes
来源:互联网 发布:百度助手 网络不可用 编辑:程序博客网 时间:2024/06/01 07:37
Palindromes
总提交 : 69 测试通过 : 40
比赛描述
Write a program that determines if each input string is a palindrome. A palindrome is a
string that reads exactly the same in both forward and reverse directions. For something
to be considered a palindrome, it must be at least 1 character long. For the purposes of
your program, ignore any characters that are not letters, as well as spaces when
determining if a string is a palindrome.
输入
The first line of input contains an integer N that indicates the number of test strings to
follow. On each subsequent line there will be a single test string. Here is a sample:
输出
For each test string, output "yes" if the string was a palindrome, and "no" if it was not a
palindrome. Remember: Ignore any characters that are not letters, as well as spaces.
样例输入
5
able ##was I, e****re I s.aw $Elba
this is not a palindrome
A man, a plan, a canal, Panama
another random string
Sator Arepo Tenet Opera Rotas
样例输出
yes
no
yes
no
yes
提示
undefined
题目来源
Internet
#include<iostream>#define MAX_N 1000char c1[MAX_N],c2[MAX_N];int main(){int N,i,j,len;scanf("%d",&N);getchar();while(N--){scanf("%[^\n]",c1);getchar();len = (int)strlen(c1);for(i=j=0;i<len;i++){if(c1[i]>='a' && c1[i]<='z'){c2[j++] = c1[i];}else if(c1[i]>='A' && c1[i]<='Z'){c2[j++] = c1[i]+'a'-'A';}}len = j;for(i=0;(i<<1)<len;i++){if(c2[i]!=c2[len-1-i]){break;}}if((i<<1)<len){printf("no\n");}else{printf("yes\n");}}}
- 南邮 OJ 1384 Palindromes
- UVa OJ 401-Palindromes
- Light OJ 1033 - Generating Palindromes
- light oj 1258 - Making Huge Palindromes(KMP)
- light OJ 1258 - Making Huge Palindromes【Manacher】
- light oj 1033 - Generating Palindromes (区间dp)
- light oj 1033 - Generating Palindromes (区间DP)
- UVa OJ 11584 - Partitioning by Palindromes
- light oj 1033 - Generating Palindromes (LCS)
- light oj 1033 - Generating Palindromes 【LCS】
- Palindromes
- Palindromes
- Palindromes
- Palindromes
- Palindromes
- Palindromes
- Palindromes
- Palindromes
- EFContext 用到的知识点
- 基于cxf webservice(1)
- 深度学习概述:从感知机到深度网络
- Looper和Handler
- POJ 1389 Area of Simple Polygons(扫描线)
- 南邮 OJ 1384 Palindromes
- DesiredCapabilities内容详解
- 华为软件编程规范和范例 4 —— 函数、过程
- Windows环境下Android Studio v1.2安装教程
- Visio 2010 激活 流程
- sql 创建链接服务器
- POJ 2431 题解
- ora-01034、ora-27101错误解决
- Convert Sorted List to Binary Search Tree