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