Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //problema 975
- #include <iostream>
- #include <cstring>
- using namespace std;
- char p[260];
- char cuvant[15];
- char favorit[15]="{";
- char sep[4]=" ,.";
- int main()
- {
- int i,j,n;
- int pozitie_inceput, pozitie_sfarsit;
- bool corect,exista=false;
- cin.getline(p,260);
- char *c=strtok(p,sep);
- while (c!=NULL)
- {
- strcpy(cuvant,c);
- n=strlen(cuvant);
- corect=true;
- for (i=0,j=n-1;i<n/2;i++,j--)
- {
- if (cuvant[i]!=cuvant[j])
- {
- corect=false;
- break;
- }
- }
- if(corect==true)
- {
- exista=true;
- // cout<<cuvant<<'\n';
- if(cuvant[0]<=favorit[0] && strlen(cuvant)>strlen(favorit))
- {
- strcpy(favorit,cuvant);
- }
- }
- c=strtok(NULL,sep);
- }
- if(exista==true)
- cout<<favorit;
- else
- cout<<"IMPOSIBIL";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement