fork(1) download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int left = 0;
  5. int right = 0;
  6.  
  7. while (s[right] != '\0') {
  8. right++;
  9. }
  10. right--;
  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.  
  23. //メイン関数は書き換えなくてよいです
  24. int main(){
  25. char s[100];
  26. scanf("%s",s);
  27. printf("%s -> %d\n",s,isPalindrome(s));
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5324KB
stdin
girafarig
stdout
girafarig -> 1