fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. //関数の中だけを書き換えてください
  5. //回文になっているとき1を返す
  6. //回文になっていないとき0を返す
  7. int len = 0;
  8.  
  9. while (s[len] != '\0') {
  10. len++;
  11. }
  12.  
  13. int left = 0;
  14. int right = len - 1;
  15.  
  16. while (left < right) {
  17. if (s[left] != s[right]) {
  18. return 0;
  19. }
  20. left++;
  21. right--;
  22. }
  23.  
  24. return 1;
  25. }
  26.  
  27. int main(){
  28. char s[100];
  29. scanf("%s",s);
  30. printf("%s -> %d\n",s,isPalindrome(s));
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5324KB
stdin
girafarig
stdout
girafarig -> 1