武汉科技大学ACM :1004: 零起点学算法74——Palindromes _easy version
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的更多相关文章
- 武汉科技大学ACM:1004: 零起点学算法36——3n+1问题
Problem Description 任给一个正整数n,如果n为偶数,就将它变为n/2,如果为奇数,则将它乘3加1(即3n+1).不断重复这样的运算,经过有限步后,一定可以得到1 . Input 输 ...
- WUOJ-ACM :1003: 零起点学算法78——牛牛
武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...
- 1163: 零起点学算法70——Yes,I can!
1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1164: 零起点学算法71——C语言合法标识符(存在问题)
1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 10 ...
- 1147: 零起点学算法54——Fibonacc
1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 20 ...
- 1145: 零起点学算法52——数组中删数II
1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 293 ...
- 1137: 零起点学算法44——多组测试数据输出II
1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1136: 零起点学算法43——多组测试数据输出I
1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: ...
- 1135: 零起点学算法42——多组测试数据(求和)IV
1135: 零起点学算法42--多组测试数据(求和)IV Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted ...
随机推荐
- 之前采用的是Helper类的方法重构时改用了扩展方法
在手机端输入网址不方全,通常会将网址做成一个二维码,然后用手机扫一下就可以打开预览.我们每改一下样式,就在手机上点一下刷新或电脑上按一下F5,这在最初的时候,也不觉得有什么问题,因为拿到我手上的静态页 ...
- allegro 的光绘层概念
TOP层: board geometry/outline manufacturing/photoplot_outline etch/top ...
- C++学习笔记--Season 2
一个简单的EGE程序: #include "graphics.h" //EGE库的头文件 int main(int argc, char** argv) { initgraph(, ...
- poj 2983Is the Information Reliable?
http://poj.org/problem?id=2983 #include<cstdio> #include<cstring> #include<algorithm& ...
- 【Java线程】Java线程池ExecutorService
示例 import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.u ...
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
如果遇到这个问题,首先考虑以下原因: 你是否在setText()方法中设置了一个int型变量,比如setText(10). 这样Android系统就会主动去资源文件当中寻找, 但是它不是一个资源文件I ...
- 《how to design programs》14章 再论自引用数据
这是一个家族谱: ;child(define-struct child (father mother name date eyes)) #lang racket ;child (define-stru ...
- HDU 1254 推箱子 BFS
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1254 题目分析: 做这道题,感觉挺简单的,做着做着就错了20次, 我也是醉了, WA到吐的节奏啊! 思 ...
- DLL入门浅析(3)——从DLL中导出变量
转载自:http://www.cppblog.com/suiaiguo/archive/2009/07/20/90643.html 前面介绍了怎么从DLL中导出函数,下面我们来看一下如何从DLL中导出 ...
- 针对Yii框架的nginx配置
我曾经针对yii制作了 个nginx配置,其中包括了以下几项内容: rewrite规则(try_file),需要nginx0.8.6版本以上支持. 针对于icon, robots.txt文件的日志优化 ...