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