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