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