题目大意:给一个字符串,判断是否回文(忽略大小写,忽略非字母字符)。

 #include <cstdio>
#include <cctype>
#include <cstring>
#define MAXN 100000 char str1[MAXN], str2[MAXN]; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
while (gets(str1))
{
if (strcmp(str1, "DONE") == ) break;
int len1 = strlen(str1), len2 = ;
for (int i = ; i < len1; i++)
if (isalpha(str1[i]))
str2[len2++] = tolower(str1[i]);
bool palindrome = true;
for (int i = , j = len2-; i < j; i++, j--)
if (str2[i] != str2[j])
{
palindrome = false;
break;
}
if (palindrome) printf("You won't be eaten!\n");
else printf("Uh oh..\n");
}
return ;
}

  今天看《演算法笔记》的时候,无意中看到了Timus,就去刷了一道A+B,美其名曰:熟悉环境,有够无聊的了...^_^

UVa 10945 - Mother bear的更多相关文章

  1. UVA 12849 Mother’s Jam Puzzle( 高斯消元 )

    题目: http://uva.onlinejudge.org/external/128/12849.pdf #include <bits/stdc++.h> using namespace ...

  2. [zz] Pixar’s OpenSubdiv V2: A detailed look

    http://www.fxguide.com/featured/pixars-opensubdiv-v2-a-detailed-look/ Pixar’s OpenSubdiv V2: A detai ...

  3. [zz]The Royal Treatment

    http://www.cgw.com/Publications/CGW/2012/Volume-35-Issue-4-June-July-2012/The-Royal-Treatment.aspx T ...

  4. CodeForces - 907A Masha and Bears

    A. Masha and Bears time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Masha and Bears(翻译+思维)

    Description A family consisting of father bear, mother bear and son bear owns three cars. Father bea ...

  6. O - Masha and Bears

    Problem description A family consisting of father bear, mother bear and son bear owns three cars. Fa ...

  7. uva 10192 Vacation(最长公共子)

    uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you ...

  8. 容斥原理--计算错排的方案数 UVA 10497

    错排问题是一种特殊的排列问题. 模型:把n个元素依次标上1,2,3.......n,求每一个元素都不在自己位置的排列数. 运用容斥原理,我们有两种解决方法: 1. 总的排列方法有A(n,n),即n!, ...

  9. Codeforces CF#628 Education 8 F. Bear and Fair Set

    F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

随机推荐

  1. 初探JavaScript魅力

    <style> #div1{width:200px; height:200px; background:red;} </style> </head> <scr ...

  2. HDU 2209 翻纸牌游戏

    翻纸牌游戏 Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submiss ...

  3. Contest - 多校训练(985专场) Problem C: 985的方格难题

    题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?cid=1157&pid=2 Description 985走入了一个n * n的方格地图, ...

  4. HDU 3696 Farm Game

    SPFA最长路,思路如下: 先对题目中给出的每条边建边,权值为转化率:增加一个终点S,每个节点到S建边,权值为该物品的单价. 假设X物品最终转化为了Y物品,那么转化之后得到的钱就是 W[x]*转化率1 ...

  5. HDU1372,BFS象棋马走日

    简单的对于bfs的运用,但是还是写的太慢了写了TMD的1H,主要是不熟悉,以后慢慢熟悉就好了,模型基本已经能建立了,主要出现bug是在方向数组的运用上面,一定要记得是从0开始的,而不是从1开始的,导致 ...

  6. LDA,PCA阅读资料

    1,线性判别分析(Linear Discriminant Analysis)(一) 2,机器学习中的数学(4)-线性判别分析(LDA), 主成分分析(PCA) 3,Machine Learning i ...

  7. Eclipse配置

    下载地址:http://www.eclipse.org/downloads/ tomcat plugin:http://www.eclipsetotale.com/tomcatPlugin.html# ...

  8. nginx 504 Gateway Time-out 解决办法

    今天用PHP执行一个非常耗时的文件[ps:自己有用,大概3分钟] 但是执行到一分钟后显示 nginx 504 Gateway Time-out 于是修改php-ini.php中的max_executi ...

  9. 让shell 变得容易理解

    1.重建你的语义模型(简单语义模型)2.变量,参数和方法命名3.测试用例4.足够的组块

  10. UIApplication,UIWindow,UIViewController,UIView(layer)

    转载自:http://www.cnblogs.com/iCocos/p/4684749.html UIApplication,UIWindow,UIViewController,UIView(laye ...