Exercice
écrire un programme en c poor vérifie si une chaine a palindrom est une chaine qui se lit aussi bien à l'envers qu'à l'endroit.
Exemple
Correction
Exercice
écrire un programme en c poor vérifie si une chaine a palindrom est une chaine qui se lit aussi bien à l'envers qu'à l'endroit.
Exemple
Correction
#include <stdio.h>
int main()
{
char text[100];
int commence, milieu, fin, length = 0;
printf("Entrez une chaîne pour vérifier s'il s'agit d'un palindrome: ");
gets(text);
while (text[length] != '\0')
{
length++;
}
fin = length - 1;
milieu = length/2;
for (commence = 0; commence < milieu; commence++)
{
if (text[commence] != text[fin])
{
printf("Not a palindrome.\n");
break;
}
fin--;
}
if (commence == milieu)
{
printf(" Palindrome.\n");
}
return 0;
}
utiliser la fonction string
#include <stdio.h>
#include <string.h>
int main()
{
char a[100], b[100];
printf("Entrez une chaîne pour vérifier s'il s'agit d'un palindrome\n");
gets(a);
strcpy(b, a);
strrev(b);
if (strcmp(a, b) == 0)
{
printf("Pas un palindrome.\n");
}
else
{
printf("palindrome.\n");
}
return 0;
}
Casinos Near Harrah's Philadelphia - Mapyro
RépondreSupprimerFind 경산 출장마사지 Casinos Near Harrah's Philadelphia in Chester, PA, United States 이천 출장마사지 - 수원 출장샵 Mapyro® delivers 군산 출장샵 high-quality real-time casino real-time 전라남도 출장샵 casino information to your