nyoj-984-最长回文
来源:互联网 发布:购物分享php系统 编辑:程序博客网 时间:2024/05/18 03:11
#include<stdio.h>
#include<string.h>
char a[110005];
int main()
{
int n,i,j;
while(scanf("%s",a)!=EOF)
{
int max=0;
n=strlen(a);
for(i=0;i<n;i++)
{
for(j=0;i-j>=0&&i+j<n;j++)
{
if(a[i-j]==a[i+j])
continue;
else break;
}
if(max<2*j-1) max=2*j-1;
for(j=0;i-j>=0&&i+j+1<n;j++)
{
if(a[i-j]==a[i+j+1])
continue;
else break;
}
if(max<2*j) max=2*j;
}
printf("%d\n",max);
}
return 0;
}
#include<string.h>
char a[110005];
int main()
{
int n,i,j;
while(scanf("%s",a)!=EOF)
{
int max=0;
n=strlen(a);
for(i=0;i<n;i++)
{
for(j=0;i-j>=0&&i+j<n;j++)
{
if(a[i-j]==a[i+j])
continue;
else break;
}
if(max<2*j-1) max=2*j-1;
for(j=0;i-j>=0&&i+j+1<n;j++)
{
if(a[i-j]==a[i+j+1])
continue;
else break;
}
if(max<2*j) max=2*j;
}
printf("%d\n",max);
}
return 0;
}
0 0
- nyoj-984-最长回文
- NYOJ 132 最长回文字符串
- NYOJ - 最长回文子串
- nyoj-132-最长回文子串
- nyoj 132-最长回文子串
- nyoj 132 最长回文子串
- nyoj 36 最长公共子序列 & nyoj 37 回文字符串
- nyoj 36最长公共子序列&&nyoj 37 回文字符串
- nyoj-37 回文字符串(最长公共子序列算法应用
- NYOJ 37 回文字符串(类似最长公共子序列)
- NYOJ-37-回文字符串(最长公共子序列)
- 最长公共子序列&回文字符串 nyoj动态规划
- NSWOJ 1228 && NYOJ 132 最长回文子串
- NYOJ 37 回文字符串 (lcs最长公共子序列)
- 最长回文
- 最长回文
- 最长回文
- 最长回文
- 冯东阳:吐胆汁分享原创文章写作经验
- CentOS(Linux) VPS 防暴力登录账户和密码
- Jquery 怎么只给点击的元素加个class(互斥)
- HDU 1599 find the mincost route 无向图最小环
- 错误 18456 ___ODBC 创建新数据源
- nyoj-984-最长回文
- javascript:void(0)链接
- [Google Guava] 2.1-不可变集合
- hdu1080 - Human Gene Functions 最长公共子序列推广
- MySQL数据类型中DECIMAL的作用和用法
- HBase技术介绍
- 西安80后大学老师离奇失踪 疑房贷等压力大
- JavaWeb入门实战—Request&Response
- webservice的学习笔记(一)