Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char s[256],*p,cuvant[11],sep[]=" ,.";
- unsigned int palindrom (char s[])
- {
- unsigned int i;
- for (i=0;i<=strlen(s)/2-1;i++)
- if(s[i]!=s[strlen(s)-i-1])
- return 0;
- return 1;
- }
- int main()
- {
- cin.get(s,256);
- cin.get();
- p=strtok(s,sep);
- char cuvmin[]="zzzzzzzzzz";
- while(p)
- {
- if(palindrom(p))
- if(strcmp(p,cuvmin)<0)
- strcpy(cuvmin,p);
- p=strtok(NULL,sep);
- }
- if(strcmp(cuvmin,"zzzzzzzzzz")==0)
- cout<<"IMPOSIBIL";
- else
- cout<<cuvmin;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement