Untitled
raw download clone
C
views 22
,
size 686 b
#include <stdio.h>
#include <string.h>

char str[2005];
int len;
int count;
void reverse(int num);

int main(void)
{
    while (scanf("%s", str) != EOF)
    {
        len = strlen(str);
        reverse(2);
        count = 0;
    }
    return 0;
}


void reverse(int num)
{
    if (num > len)
    {
        printf("%d\n", count);
        return;
    }
    char temp;
    //printf("  %d  ", num);
    for (int i = 0;i <= len - num;i++)
    {
        int flag = 0;
        for (int j = 0;j < num / 2;j++)
        {
            if (str[i + j] != str[i + num - 1 - j]) flag = 1;
        }
        if (flag == 0) count++;
    }
    reverse(num + 1);
}
close fullscreen
Login or Register to edit or fork this paste. It's free.