Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char a[256],cuv[256][256],*p,separator[]=" ";
- cin.get(a,256);
- p=a;
- p=strtok(p,separator);
- int nr=0;
- while(p)
- strcpy(cuv[++nr],p),p=strtok(NULL,separator);
- int Lit[27]={0},D[nr+1];
- for(int i=1;i<=nr;++i)
- {
- for(int j=0;j<26;++j)
- Lit[j]=0;
- D[i]=0;
- for(unsigned int j=0;j<strlen(cuv[i]);++j)
- ++Lit[cuv[i][j]-'a'];
- for(int j=0;j<26;++j)
- {
- if(Lit[j]==1)
- ++D[i];
- if(Lit[j]>1)
- {
- D[i]=0;
- break;
- }
- }
- }
- int Max=0,t=0;
- for(int i=1;i<=nr;++i)
- if(D[i]>Max)
- t=i,Max=D[i];
- if(Max<2)
- cout<<-1<<'\n';
- else
- cout<<cuv[t]<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement