fork download
  1. # include <stdio.h>
  2. # include <string.h>
  3. int isPalindrome(char s[]) {
  4. int left=0;
  5. int right=strlen(s)-1;
  6. while(left<right){
  7. if(s[left]!=s[right]){
  8. return 0;}
  9. left++;
  10. right--;
  11. }
  12. return 1;}
  13.  
  14. //メイン関数は書き換えなくてよいです
  15. int main(){
  16. char s[100];
  17. scanf("%s",s);
  18. printf("%s -> %d\n",s,isPalindrome(s));
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5276KB
stdin
girafarig
stdout
girafarig -> 1