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