Advertisement
a53

Cuvinte2

a53
Jun 6th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. char s[256],*p,cuvant[11],sep[]=" ,.";
  4. unsigned int palindrom (char s[])
  5. {
  6. unsigned int i;
  7. for (i=0;i<=strlen(s)/2-1;i++)
  8. if(s[i]!=s[strlen(s)-i-1])
  9. return 0;
  10. return 1;
  11. }
  12. int main()
  13. {
  14. cin.get(s,256);
  15. cin.get();
  16. p=strtok(s,sep);
  17. char cuvmin[]="zzzzzzzzzz";
  18. while(p)
  19. {
  20. if(palindrom(p))
  21. if(strcmp(p,cuvmin)<0)
  22. strcpy(cuvmin,p);
  23. p=strtok(NULL,sep);
  24. }
  25. if(strcmp(cuvmin,"zzzzzzzzzz")==0)
  26. cout<<"IMPOSIBIL";
  27. else
  28. cout<<cuvmin;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement