| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大牛帮帮忙,看看这种思路有没有错啊#include"stdio.h"
#include"string.h"
#include"stdlib.h"
int main()
{
int i,j,k,m,n;
char s[10000];
scanf("%d",&n);
scanf("%s",s);
k=0;
i=0;j=n-1;
while(j>=i)
{
if(s[i]==s[j])
{
i++;
j--;
}
else
{
if(s[i+1]==s[j]||s[i]==s[j-1])
{
if(s[i+1]==s[j])
{
k++;
i++;
}
if(s[i]==s[j-1])
{
k++;
j--;
}
}
else
{
k+=2;
i++;
j--;
}
}
}
printf("%d\n",k);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator