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