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