CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: c to java

  1. #1
    Join Date
    May 2015
    Posts
    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");

    }
    }

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    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
  •  





Click Here to Expand Forum to Full Width

Featured