Advertisement
iasmina_sarac

Untitled

Nov 13th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. int pal(char[s])
  5. {
  6. int i,j;
  7. i=0;
  8. j=strlen(s)-1;
  9. while(i<j)
  10. {
  11. if(s[i]!=s[j])
  12. return 0;
  13. i++;
  14. j--;
  15. }
  16. }
  17. int main()
  18. {
  19. char s[256], *p, cuvp[100], sep[]=" .,;?!";
  20. int ok=0;
  21. cin.getline(s,255);
  22. p=strtok(s, sep);
  23. while(p)
  24. {
  25. if(pal(p))
  26. {
  27. if(!ok)
  28. {
  29. strcpy(cuvp,p);
  30. ok=1;
  31. }
  32. if(strcmp(p,cuv)<0)
  33. strcpy(cuvp,p);
  34. }
  35. p=strtok(NULL,sep);
  36. }
  37. if(ok)
  38. cout<<cuvp;
  39. else
  40. cout<<" "
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement