30 lines
497 B
C
30 lines
497 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
char* inverse(const char* s){
|
||
|
int i;
|
||
|
int e=0;
|
||
|
char* crocs;
|
||
|
int longueur = (int) strlen(s);
|
||
|
crocs = (char*) malloc(longueur+1);
|
||
|
for (i=longueur-1;i>=0;--i) {
|
||
|
crocs[e] = s[i];
|
||
|
e++;
|
||
|
crocs[longueur] = '\0';
|
||
|
}
|
||
|
return crocs;
|
||
|
}
|
||
|
|
||
|
int main(int argc, char** argv) {
|
||
|
int c;
|
||
|
for(c=1; c< argc; c++){
|
||
|
if (strcmp(argv[c], inverse(argv[c]))== 0){
|
||
|
printf("est un palindrome \n");
|
||
|
}
|
||
|
else{
|
||
|
printf("non \n");
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|