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