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