天天看点

九度OJ 1192:回文字符串

题目1192:回文字符串

时间限制:1 秒内存限制:32 兆  特殊判题:否提交:3659 解决:1718

题目描述:
给出一个长度不超过1000的字符串,判断它是不是回文(顺读,逆读均相同)的。
输入:
输入包括一行字符串,其长度不超过1000。
输出:
可能有多组测试数据,对于每组数据,如果是回文字符串则输出"Yes!”,否则输出"No!"。
样例输入:
hellolleh
helloworld      
样例输出:
Yes!
No!      

注意:此题为:九度OJ 题目1192:回文字符串

说明:无

已AC源代码:

#include<stdio.h> 
#include<string.h> 
int main() 
{
	char ch[1100];
	int i,j,len,temp;     
	while(~scanf("%s",ch))     
	{     
		len=strlen(ch);         
		temp=1;         
		for(i=0,j=len-1;i<=j;++i,--j)         
		{       
			if(ch[i]!=ch[j])             
			{             
				temp=0;              
				break;
			}
		}
		if(temp)
			printf("Yes!\n");
		else
			printf("No!\n");
	}
	return 0;
}
/**************************************************************     
Problem: 1192     
User: 守望天空     
Language: C++     
Result: Accepted     
Time:10 ms     
Memory:1020 kb 
****************************************************************/