Problem Description

“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。请写一个程序判断读入的字符串是否是“回文”。

Input

输入包含多个测试实例,输入数据的第一行是一个正整数n,表示测试实例的个数,后面紧跟着是n个字符串。每个字符串长度不超过150。

Output

如果一个字符串是回文串,则输出"yes",否则输出"no".

Sample Input

4

level

abcde

noon

haha

Sample Output

yes

no

yes

no

 #include<stdio.h>

 #include<string.h>

 int fun(char a[])

 {       

          int i,k,r=;        

          k=strlen(a)-;  

          for(i=;i<=k;k--,i++)          

          {                

                    if(a[i]!=a[k])                        

                    {                          

                             r=;

                             break;

                    }

          }

          return r;

 }

 int main()

 {

          char a[];

          int i,n;

          scanf("%d",&n);

          for(i=;i<n;i++)

          {

                    scanf("%s",&a);

                    if(fun(a)==)

                             printf("no\n");

                    else

                             printf("yes\n");

          }

          return ;

 }
#include<stdio.h>
#include<string.h>
int main()
{
char str[];
int n,i,j;
scanf("%d",&n);
while(n>)
{
scanf("%s",str);
i=;
j=strlen(str)-;
while(i<=j)
{
if(str[i]!=str[j])
break;
i++;
j--;
}
if(i>j)
printf("yes\n");
else
printf("no\n");
n--;
}
return ;
}

武汉科技大学ACM :1004: 零起点学算法74——Palindromes _easy version的更多相关文章

  1. 武汉科技大学ACM:1004: 零起点学算法36——3n+1问题

    Problem Description 任给一个正整数n,如果n为偶数,就将它变为n/2,如果为奇数,则将它乘3加1(即3n+1).不断重复这样的运算,经过有限步后,一定可以得到1 . Input 输 ...

  2. WUOJ-ACM :1003: 零起点学算法78——牛牛

    武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...

  3. 1163: 零起点学算法70——Yes,I can!

    1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: ...

  4. 1164: 零起点学算法71——C语言合法标识符(存在问题)

    1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 10 ...

  5. 1147: 零起点学算法54——Fibonacc

    1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 20 ...

  6. 1145: 零起点学算法52——数组中删数II

    1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: 293 ...

  7. 1137: 零起点学算法44——多组测试数据输出II

    1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted: ...

  8. 1136: 零起点学算法43——多组测试数据输出I

    1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec  Memory Limit: 128 MB   64bit IO Format: %lldSubmitted: ...

  9. 1135: 零起点学算法42——多组测试数据(求和)IV

    1135: 零起点学算法42--多组测试数据(求和)IV Time Limit: 1 Sec  Memory Limit: 64 MB   64bit IO Format: %lldSubmitted ...

随机推荐

  1. codevs 1217 借教室

    传送门 1217 借教室 2012年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Descripti ...

  2. 反射-b

    Class pkClass=NSClassFromString(@"PKAddPassesViewController");    if (pkClass) {        NS ...

  3. 转:/etc/inittab文件的字段及其说明

    /etc/inittab文件中每个登记项的结构都是一样的,共分为以冒号“:”分隔的4个字段.具体如下:       identifier :  run_level  :  action  :  pro ...

  4. poj 1606Jugs

    http://poj.org/problem?id=1606 #include<cstdio> #include<cstring> #define MAXN 1000000 u ...

  5. DC DC降壓變換器ic 工作原理

    目前DC/DC轉化器大致可分為:升壓型dc dc變化器.降壓型dc dc變化器及可升壓又可降壓dc dc變換器.我們今天主要提一下降壓型dc dc變換器的原理: 見下圖降壓變換器原理圖如圖1所示, 當 ...

  6. RR 和RC 幻读问题

    <pre name="code" class="html">显然 RR 支持 gap lock(next-key lock),而RC则没有gap l ...

  7. Codeforces Round #312 (Div. 2) C.Amr and Chemistry

    Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experime ...

  8. COJ 0579 4020求次短路的长度

    4020求次短路的长度 难度级别:C: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 在一个地图上共有N个路口(编号分别为1到N),R条道路( ...

  9. -_-#【Angular】依赖注入

    AngularJS学习笔记 var BoxCtrl = function($scope, $element) { } var str = BoxCtrl.toString().replace(/\s/ ...

  10. -_-#【Mac】命令

    切换cd $HOMEcd ~ 查看ls 查看系统显示:defaults write com.apple.finder AppleShowAllFiles -bool true隐藏:defaults w ...