-
May 17th, 2015, 12:31 PM
#1
c to java
#include<stdio.h>
#include<string.h>
int main()
{
int t,l,i,j,k,end_start_flag=0,middle_flag=0,p,m;
scanf("%d",&t);
char array[9999];
while(t--)
{
scanf("%s",array);
scanf("%d",&m);
l = strlen(array);
k=l-1;
i=0,j=0;
while(array[i]!=array[k])
{
i++;
j++;
}
p = j;
end_start_flag=0;
while(array[i]==array[k] && j>=0)
{
i--;
k--;
j--;
}
if(i== -1)
{
end_start_flag=1;
}
j=0;
for(i=p+1;i<m;i++)
{
if(array[i]==array[j])
{
p--;
j++;
}
if(p==-1)
{
middle_flag=1;
break;
}
}
if(end_start_flag == 1 && middle_flag == 1)
{
printf("Yes\n");
}
else
printf("No");
}
}
-
May 18th, 2015, 10:36 AM
#2
Re: c to java
ahoodin
To keep the plot moving, that's why.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|