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