http://acm.hdu.edu.cn/showproblem.php?pid=2163

Problem Description
Write a program to determine whether a word is a palindrome. A palindrome is a sequence of characters that is identical to the string when the characters are placed in reverse order. For example, the following strings are palindromes: “ABCCBA”, “A”, and “AMA”. The following strings are not palindromes: “HELLO”, “ABAB” and “PPA”. 
 
Input
The input file will consist of up to 100 lines, where each line contains at least 1 and at most 52 characters. Your program should stop processing the input when the input string equals “STOP”. You may assume that input file consists of exclusively uppercase letters; no lowercase letters, punctuation marks, digits, or whitespace will be included within each word. 
 
Output
A single line of output should be generated for each string. The line should include “#”, followed by the problem number, followed by a colon and a space, followed by the string “YES” or “NO”. 
 
Sample Input
ABCCBA
A
HELLO
ABAB
AMA
ABAB
PPA
STOP
 
Sample Output
#1: YES
#2: YES
#3: NO
#4: NO
#5: YES
#6: NO
#7: NO
 
代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
char s[maxn], ss[maxn]; int main() {
int cnt = 0;
while(gets(s)) {
int len = strlen(s);
if(s[0] == 'S' && s[1] == 'T' && s[2] == 'O' && s[3] == 'P' && len == 4)
break;
cnt ++;
strcpy(ss, s);
strrev(s);
printf("#%d: ", cnt);
if(strcmp(ss, s) == 0)
printf("YES\n");
else printf("NO\n");
}
return 0;
}

  

HDU 2163 Palindromes的更多相关文章

  1. HDOJ/HDU 2163 Palindromes(判断回文串~)

    Problem Description Write a program to determine whether a word is a palindrome. A palindrome is a s ...

  2. hdu 1318 Palindromes(回文词)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1318 题意分析:输入每行包含一个字符串,判断此串是否为回文串或镜像串. 表面上看这道题有些复杂,如果能 ...

  3. hdu 1318 Palindromes

    Palindromes Time Limit:3000MS     Memory Limit:0KB     64bit                                         ...

  4. HDU 1544 Palindromes(回文子串)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1544 问题分析: 问题要求求出字符串的连续子串中的回文子串个数.首先,需要区分连续子串与子序列的区别. ...

  5. HDU 2029 Palindromes _easy version

    http://acm.hdu.edu.cn/showproblem.php?pid=2029 Problem Description “回文串”是一个正读和反读都一样的字符串,比如“level”或者“ ...

  6. hdu 3948 The Number of Palindromes

    The Number of Palindromes Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (J ...

  7. HDU - 5340 Three Palindromes(manacher算法)

    http://acm.hdu.edu.cn/showproblem.php?pid=5340 题意 判断是否能将字符串S分成三段非空回文串 分析 manacher预处理出前缀和后缀回文的位置, 枚举第 ...

  8. HDU 5340——Three Palindromes——————【manacher处理回文串】

    Three Palindromes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  9. hdu 5340 Three Palindromes

    前几晚 BC 的第二题,官方给出的题解是: 然后我结合昨天刚看的 Manacher 算法试着写了下,发现 pre.suf 数组挺难构造的,调试了好久,然后就对中间进行枚举了,复杂度应该是 O(n2) ...

随机推荐

  1. Python学习知识库

    2017年10月16日 1. too broad exception clause 捕获的异常过于宽泛了,没有针对性,应该指定精确的异常类型场景: def check_data_type(column ...

  2. Linux字符设备驱动--No.2

    分析中断注册函数:request_irq int butsOpen(struct inode *p, struct file *f) { int irq; int i; ; printk(KERN_E ...

  3. java 递归打印20个斐波那契数

    class Test { public static void main(String[] args) { // feibo j=new feibo(); for (int n = 1; n < ...

  4. C语言学习记录

    思路: 工具书: <c程序设计语言> R&K <linux C 编程一站式学习>

  5. HyperLedger Fabric 1.4 生产环境使用ca生成msp和tls(12)

    在上一章:Fabric kafka生产环境部署的基础上部署Fabric CA,使用Fabric CA进行生成公私钥和证书等文件,全部替换cryptogen工具,包括生成TLS相关的私钥和证书等文件.  ...

  6. Java基础之static关键字的用法

    Java中的static关键字主要用于内存管理.我们可以应用static关键字在变量.方法.块和嵌套类中. static关键字属于类,而不是类的实例.        静态(static)可以是: 变量 ...

  7. GitHub 配置指南

    Git和GitHub的区别 GitHub术语解析 配置使用 注册GitHub帐号 创建Git 创建库 复制库 社交化 Git和GitHub的区别 Git是一个分布式的版本控制系统,与SVN类似:最初由 ...

  8. MAC 更新brew 镜像源

    mac 更新brew镜像源 cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url o ...

  9. 05-JVM对象探秘

    一.对象的内存布局         以Hotspot虚拟机为例,对象在内存中的结构可以分为三部分:对象头(header).实例数据(instance data).对齐填充(padding). 1.1. ...

  10. java对象创建过程简介

    这是看书的记录,字有点丑啊还是将就搬上来 -.-,等把后面看了完善图