Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define TRUE 1
  4. #define FALSE 0
  5.  
  6. int palindrom(char *a, int count)
  7. {
  8. int i = 0;
  9. while(i<=count)
  10. {
  11. if (a[i]!=a[count-1])
  12. return FALSE;
  13. i++;
  14. count--;
  15. }
  16. return TRUE;
  17. }
  18.  
  19. int main()
  20. {
  21. char s[256];
  22. FILE *f1=fopen("karin.txt","r");
  23. FILE *f2=fopen("karout.txt","w");
  24. while(fscanf(f1,"%s",s))
  25. {
  26. if (palindrom(s, strlen(s)))
  27. fprintf(f2,"yes ");
  28. else
  29. fprintf(f2,"no ");
  30. if (feof(f1))
  31. break;
  32. }
  33. fclose(f1);
  34. fclose(f2);
  35. return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement