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