fork download
  1. #include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int i = 0;
  5. int j = 0;
  6.  
  7.  
  8. while (s[j] != '\0') {
  9. j++;
  10. }
  11. j--;
  12.  
  13. while (i < j) {
  14. if (s[i] != s[j]) {
  15. return 0;
  16. }
  17. i++;
  18. j--;
  19. }
  20.  
  21. return 1;
  22. }
  23.  
  24. // メイン関数はそのままでOK
  25. int main(){
  26. char s[100];
  27. scanf("%s",s);
  28. printf("%s -> %d\n",s,isPalindrome(s));
  29. return 0;
  30. }
Success #stdin #stdout 0s 5300KB
stdin
ajbdgbujhjl
stdout
ajbdgbujhjl -> 0