Untitled
raw download clone
TEXT
views 17
,
size 1278 b
#include <stdio.h>
#include<string.h>

char a[100009], a_right[100009], a_left[100009], b[100009], b_right[100009], b_left[100009];

int check(char a, char b, char a_right, char a_left, char b_right, char b_left)
{
    if(a == b)
        return 1;
    else //a,b different. len(a,b) must be even.
    {
        if((a_left == b_right) && (a_right == b_left))
            return 1;
        else
            return 0;
    }
}
int main()
{
    int i, ans;
    /*建立陣列*/
    scanf("%s", a);
    scanf("%s", b);
    if(strlen(a)%2 == 0)
    {
        for(i=0 ; i<strlen(a)/2 ; i++)
        {
            a_left[i] = a[i];
            a_right[i] = a[(strlen(a)/2)+i];
        }
    }
    if(strlen(b)%2 == 0)
    {
        for(i=0 ; i<strlen(b)/2 ; i++)
        {
            b_left[i] = b[i];
            b_right[i] = b[(strlen(a)/2)+i];
        }
    }
    /*開始判斷*/
    if( strlen(a)%2 == 0  ) //len(a,b) = even
    {
        ans = check(a, b, a_right, a_left, b_right, b_left);
        if(ans == 1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    else //len = odd
    {
        if(a ==b)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.