fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4.  
  5. int len = 0;
  6. int i;
  7.  
  8. while (s[len] != '\0') {
  9. len++;
  10. }
  11.  
  12. int j = len - 1;
  13.  
  14. for (i = 0; i < j; i++, j--) {
  15. if (s[i] != s[j]) {
  16. return 0;
  17. }
  18. }
  19.  
  20. return 1;
  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 5320KB
stdin
girafarig
stdout
girafarig -> 1