fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int len = 0;
  5.  
  6. while (s[len] != '\0') {
  7. len++;
  8. }
  9.  
  10. for (int i = 0; i < len / 2; i++) {
  11. if (s[i] != s[len - 1 - i]) {
  12. return 0; //回文になっていないとき0を返す)
  13. }
  14. }
  15.  
  16. return 1; //回文になっているとき1を返す
  17.  
  18. }
  19.  
  20.  
  21. int main(){
  22. char s[100];
  23. scanf("%s",s);
  24. printf("%s -> %d\n",s,isPalindrome(s));
  25. return 0;
  26. }
  27.  
  28.  
Success #stdin #stdout 0s 5320KB
stdin
repaper
stdout
repaper -> 1