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