fork download
  1. #include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. //関数の中だけを書き換えています
  5. int len = 0;
  6. while (s[len] != '\0') {
  7. len++;
  8. }
  9. int left = 0;
  10. int right = len - 1;
  11.  
  12. while (left < right) {
  13. if (s[left] != s[right]) {
  14. return 0;
  15. }
  16. left++;
  17. right--;
  18. }
  19. return 1;
  20. }
  21. //メイン関数は書き換えなくてよいです
  22. int main(){
  23. char s[100];
  24. scanf("%s",s);
  25. printf("%s -> %d\n",s,isPalindrome(s));
  26. return 0;
  27. }
Success #stdin #stdout 0s 5316KB
stdin
girafarig
stdout
girafarig -> 1