Tuesday, July 24, 2018

Code vita Round 2(2014)

Cyclic Palindrome?

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    char s[100],d[100],b[100];
    int i,f[10]={1,1,1,1,1,1,1,1,1,1},j,n,k;
    scanf("%d",&n);
    for(k=0;k<=n;k++)
    {
    strcpy(s,"\0");
    gets(s);
    i=strlen(s);
    d[0]=s[i-1];
    d[1]='\0';
    s[i-1]='\0';
    strcat(d,s);
    for(j=0,i=i-1;i>=0;i--,j++)
    {
        b[j]=d[i];
    }
    b[j]='\0';
    f[k]=strcmp(d,b);
    }
    for(i=1;i<=n;i++)
    {
    if(f[i]==0)
    printf("1\n");
    else
    printf("-1\n");
    }
    return 0;
}

1 comment:

  1. Playtech Casinos in Arizona 2021 - Dr.MCD
    The best online aprcasino casino games at Dr.MCD If you prefer 토토 사이트 모음 the traditional https://febcasino.com/review/merit-casino/ slot 출장샵 machines, or prefer sol.edu.kg games with progressive jackpots, then

    ReplyDelete