fork download
  1. #include <stdio.h>
  2.  
  3. int isPalindrome(char s[]) {
  4. int i = 0;
  5. int c;
  6. int j;
  7.  
  8. while (s[i] != '\0') {
  9. i++;
  10. }
  11.  
  12. c = i - 1;
  13. for (j = 0; j <= c / 2; j++) {
  14. if (s[j] != s[c - j]) {
  15. return 0;
  16. }
  17. }
  18. return 1;
  19. }
  20.  
  21. //メイン関数は書き換えなくてよいです
  22. int main(void) {
  23. char s[100];
  24.  
  25. scanf("%99s", s);
  26. printf("%s -> %d\n", s, isPalindrome(s));
  27.  
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 5332KB
stdin
Standard input is empty
stdout
 -> 1