fork download
  1. # include <stdio.h>
  2.  
  3. int isPalindrome(char s[]){
  4. int i = 0, j = 0;
  5.  
  6. while(s[j] != '\0'){
  7. j++;
  8. }
  9.  
  10. j--;
  11.  
  12. while(i < j){
  13. if(s[i] != s[j]){
  14. return 0;
  15. }
  16. i++;
  17. j--;
  18. }
  19. return 1;
  20. }
  21.  
  22. int main(){
  23. char s[100];
  24. scanf("%s",s);
  25. printf("%s -> %d\n",s,isPalindrome(s));
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5292KB
stdin
girafarig
stdout
girafarig -> 1