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