fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int i;
  5. while(s[i]!='\0'){
  6. i++;
  7. }
  8. int p;
  9. for(p=0;p<i/2;p++){
  10. if(s[p]!=s[i-1-p]){
  11. return 0;
  12. }
  13. }
  14.  
  15. return 1;
  16.  
  17. //関数の中だけを書き換えてください
  18. //回文になっているとき1を返す
  19. //回文になっていないとき0を返す
  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 5320KB
stdin
girafarig
stdout
girafarig -> 1