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.  
  11. while (s[j] != '\0') j++;
  12. j--;
  13.  
  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. //メイン関数は書き換えなくてよいです
  28. int main(){
  29. char s[100];
  30. scanf("%s",s);
  31. printf("%s -> %d\n",s,isPalindrome(s));
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5312KB
stdin
girafarig
stdout
girafarig -> 1