- #include<iostream.h>
- #include<string.h>
-
-
- bool palyndrome (char word[], int n, int m)
- {
- int i;
- for (i=0;i<m;i++) if (word[i]!=word[n-i-1]) return false;
- return true;
- }
-
- void majuscule(char &lettre)
- {
- if ((lettre>='a')&&(lettre<='z')) lettre=lettre-32;
- }
-
- void main()
- {
- int i,n,m;
- char word[21];
- bool pal;
- cout<<"Tapez votre mot : ";cin>>word;
- n=strlen(word);
- m=n/2;
- for (i=0;i<n;i++) majuscule(word[i]);
- cout<<word<<endl;
- pal=palyndrome(word,n,m);
- if (pal==true) cout<<"C'est un palyndrome"<<endl;
- else cout<<"Ce n'est pas un palyndrome"<<endl;
- }
#include<iostream.h>
#include<string.h>
bool palyndrome (char word[], int n, int m)
{
int i;
for (i=0;i<m;i++) if (word[i]!=word[n-i-1]) return false;
return true;
}
void majuscule(char &lettre)
{
if ((lettre>='a')&&(lettre<='z')) lettre=lettre-32;
}
void main()
{
int i,n,m;
char word[21];
bool pal;
cout<<"Tapez votre mot : ";cin>>word;
n=strlen(word);
m=n/2;
for (i=0;i<n;i++) majuscule(word[i]);
cout<<word<<endl;
pal=palyndrome(word,n,m);
if (pal==true) cout<<"C'est un palyndrome"<<endl;
else cout<<"Ce n'est pas un palyndrome"<<endl;
}