fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int left = 0;
  5. int right = 0;
  6.  
  7. while(s[right] != '\0'){
  8. right++;
  9. }
  10. right--;
  11. while(left < right){
  12. if(s[left] != s[right]){
  13. return 0;
  14. }
  15. left++;
  16. right--;
  17. }
  18.  
  19. return 1;
  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 5284KB
stdin
girafarig
stdout
girafarig -> 1