31 lines
612 B
C
31 lines
612 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
char* inverse(const char* s){
|
|
int ind=0,i;
|
|
char lettre;
|
|
char* tab_inv=(char*) malloc((strlen(s)+1)*sizeof(char));
|
|
for(i=strlen(s)-1; i>=0;i--){
|
|
tab_inv[ind]=s[i];
|
|
ind++;
|
|
}
|
|
tab_inv[ind]='\0';
|
|
return tab_inv;
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
int mot;
|
|
char* arg=NULL;
|
|
for (mot=1;mot<argc;mot++){
|
|
arg=inverse(argv[mot]);
|
|
if (strcmp(arg,argv[mot])==0)
|
|
printf("%s est un palindrome",argv[mot]);
|
|
else
|
|
printf("%s n'est pas un palindrome",argv[mot]);
|
|
if (mot<argc-1)
|
|
printf(",\n");
|
|
}
|
|
printf(".\n");
|
|
return EXIT_SUCCESS;
|
|
} |