#include <stdio.h>
#include <ctype.h>
#include <string.h>

int palindromo(char *a, char *b)
{
	int i,j,n;
	char str[50];
	
    for (i=0;i<strlen(a);i++)
      str[i]=a[i];
    for (j=0;j<strlen(b);j++)
      str[i+j]=b[j];
      str[i+j]='\0';
	n=strlen(str);
	if (n==0) return 0;
	for (i=0;i<(n/2);i++)
	 {
      if (str[i]!=str[n-i-1])
        return 0;
     }
     return 1;
}



int main(void)
{

	char str1[21], str2[21], a[21], b[21],ch;
	int res;

	printf("Inserisci 2 stringhe separate da spazio o acapo.\n");
	scanf("%20[A-Za-z0-9',!] %20[A-Za-z0-9',!]", str1, str2);
	printf("Ho letto '%s' e '%s'\n", str1,str2);
	int i=0, j=0;
	while ((i<20)&&(str1[i]!='\0'))
	{
	  if (isalpha(str1[i]))
	  {
	  a[j]=str1[i];
	  j++;
	  }
	  i++;
	}
	a[j]='\0';
    i=0;
    j=0;
	while ((i<20)&&(str2[i]!='\0'))
	{
	  if (isalpha(str2[i]))
	  {
	  b[j]=str2[i];
	  j++;
	  }
	  i++;
	}
	b[j]='\0';
	res=palindromo(a,b);
	if (res==1)
	  printf("'%s%s' e' palindroma\n",a,b);
	else
	  printf("'%s%s' non e' palindroma\n",a,b);
      scanf("%s", &ch);
	return(0);
}

