fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. //関数の中だけを書き換えてください
  5. //回文になっているとき1を返す
  6. //回文になっていないとき0を返す
  7.  
  8. int len=0;
  9. int j;
  10.  
  11. while(s[len]!='\0'){
  12. len++;
  13. }
  14.  
  15. j=len-1;
  16.  
  17. for(int i=0;i<len/2;i++){
  18. if(s[i]!=s[j]){
  19. return 0;
  20. }
  21. j--;
  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 0.01s 5284KB
stdin
girafarig
stdout
girafarig -> 1