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