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