fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. //関数の中だけを書き換えてください
  5. //回文になっているとき1を返す
  6. //回文になっていないとき0を返す
  7. int i = 0;
  8. int j = 0;
  9.  
  10. while (s[j] != '\0'){
  11. j++;
  12. }
  13. j--;
  14.  
  15. while (i < j){
  16. if (s[i] != s[j]){
  17. return 0;
  18. }
  19. i++;
  20. j--;
  21. }
  22.  
  23. return 1;
  24. }
  25.  
  26. //メイン関数は書き換えなくてよいです
  27. int main(){
  28. char s[100];
  29. scanf("%s",s);
  30. printf("%s -> %d\n",s,isPalindrome(s));
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5292KB
stdin
girafarig
stdout
girafarig -> 1