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. while (s[j] != '\0') {
  10. j++;
  11. }
  12. j--;
  13. while (i < j) {
  14. if (s[i] != s[j]) {
  15. return 0;
  16. }
  17. i++;
  18. j--;
  19. }
  20. return 1; // 回文の場合
  21. }
  22.  
  23. //メイン関数は書き換えなくてよいです
  24. int main(){
  25. char s[100];
  26. scanf("%s",s);
  27. printf("%s -> %d\n",s,isPalindrome(s));
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5288KB
stdin
girafarig
stdout
girafarig -> 1