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