1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
int nbLivres, i=0, h=0, j=0, total=0, longueur=0, longueurBis=0, longueurBis2=0;
char titre[101];
char titreBis[101];
scanf("%d\n", &nbLivres);
for(i=0;i<nbLivres;i++)
{
total=0;
scanf("%[^\n]\n", titre);
longueur=strlen(titre);
// strcpy(titreBis,titre); // copier titre dans titreBis
for(i=0;i<longueur;i++)
{
if(titre[i]!=' ')
{
titreBis[j]=toupper(titre[i]); // titre en maj
j++;
}
}
titreBis[j]='\0';
longueurBis=strlen(titreBis);
if(longueurBis==1)
{
printf("%s\n", titre);
}
else if(longueurBis%2==1)
{
longueurBis2=(longueurBis-1)/2;
for(i=0, h=longueurBis-1;i<h;i++,h--)
{
if(titreBis[i]==titreBis[h])
{
total++;
if(total==longueurBis2)
{
printf("%s\n", titre);
}
}
}
}
}
return 0;
} |
Partager