SHARE
TWEET

Untitled

a guest Jan 20th, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int palindrom(char s[])
  6. {
  7.     int i, OK=1;
  8.     for(i=0;i<strlen(s)/2;i++)
  9.         if(s[i]!=s[strlen(s)-1-i])
  10.         OK=0;
  11.     return OK;
  12. }
  13.  
  14.  
  15.  
  16. int main()
  17. {
  18.     char s[256],*p,sep[]=" ,.", pal[11];
  19.     cin.get(s,256);pal[0]='\0';
  20.     p=strtok(s,sep);
  21.     while(p!=NULL)
  22.     {
  23.         if(palindrom(p)==1)
  24.             if(pal[0]=='\0')
  25.                 strcpy(pal,p);
  26.             else
  27.                 if(strcmp(pal,p)==1)
  28.                     strcpy(pal,p);
  29.         p=strtok(NULL,sep);
  30.     }
  31.     if(pal[0]=='\0')
  32.         cout<<"IMPOSIBIL";
  33.         else cout<<pal;
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top