Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- using namespace std;
- int pal(char[s])
- {
- int i,j;
- i=0;
- j=strlen(s)-1;
- while(i<j)
- {
- if(s[i]!=s[j])
- return 0;
- i++;
- j--;
- }
- }
- int main()
- {
- char s[256], *p, cuvp[100], sep[]=" .,;?!";
- int ok=0;
- cin.getline(s,255);
- p=strtok(s, sep);
- while(p)
- {
- if(pal(p))
- {
- if(!ok)
- {
- strcpy(cuvp,p);
- ok=1;
- }
- if(strcmp(p,cuv)<0)
- strcpy(cuvp,p);
- }
- p=strtok(NULL,sep);
- }
- if(ok)
- cout<<cuvp;
- else
- cout<<" "
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement