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