Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <fstream>
- #define N 301
- using namespace std;
- char s[N], pmax[N];
- bool ok;
- void elimin(char s[])
- {
- char t[N] ; int k=0;
- for(int i=0;s[i]; i++)
- if(s[i]>='a'&& s[i]<='z') t[k++]=s[i];
- t[k]=NULL;
- strcpy(s,t);
- }
- bool palindrom(char s[])
- {
- int n=strlen(s);
- for(int i=0; i<n/2;i++)
- if(s[i]!=s[n-i-1])return 0;
- return 1;
- }
- void Citire()
- {
- //ifstream cin("date.in");
- while(cin>>s)
- {
- elimin(s);
- if(palindrom(s))
- {
- if(ok==0) strcpy(pmax,s);
- else
- if(strcmp(pmax,s)>0)strcpy(pmax,s);
- ok=1;
- }
- }
- cout<<pmax;
- }
- int main()
- {
- Citire();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement