fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int isSameChar(char a, char b){
  5. return a == b || abs(a-b) == abs('A'-'a');
  6. }
  7. int getline(char s[], int lim){
  8. int c, i;
  9. for(i = 0; i < lim-1 && (c=getchar()) != EOF && c != '\n'; ++i)
  10. s[i] = c;
  11. s[i] = '\0';
  12. return i;
  13. }
  14.  
  15. int main(void){
  16. char buf[1024], str[1024];
  17. getline(buf, 1024);
  18. int i, j = 0;
  19. for(i = 0; buf[i] != '\0'; ++i){
  20. if(('a' <= buf[i] && buf[i] <= 'z') || ('A' <= buf[i] && buf[i] <= 'Z')){
  21. str[j++] = buf[i];
  22. str[j] = '\0';
  23. }
  24. }
  25. puts(str);
  26. --j;
  27. for(i = j; i >= 0; --i) putchar(str[i]);
  28. putchar('\n');
  29. for(i = 0; i <= j; ++i, --j){
  30. if(!isSameChar(str[i], str[j])) break;
  31. }
  32. if(i > j) puts("Palindrome!");
  33. return 0;
  34. }
  35.  
  36.  
  37.  
  38.  
Success #stdin #stdout 0.01s 1724KB
stdin
Damn! I, Agassi, miss again! Mad
stdout
DamnIAgassimissagainMad
daMniagassimissagAInmaD
Palindrome!