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