Advertisement
a53

DistLungMax

a53
Dec 27th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char a[256],cuv[256][256],*p,separator[]=" ";
  8. cin.get(a,256);
  9. p=a;
  10. p=strtok(p,separator);
  11. int nr=0;
  12. while(p)
  13. strcpy(cuv[++nr],p),p=strtok(NULL,separator);
  14. int Lit[27]={0},D[nr+1];
  15. for(int i=1;i<=nr;++i)
  16. {
  17. for(int j=0;j<26;++j)
  18. Lit[j]=0;
  19. D[i]=0;
  20. for(unsigned int j=0;j<strlen(cuv[i]);++j)
  21. ++Lit[cuv[i][j]-'a'];
  22. for(int j=0;j<26;++j)
  23. {
  24. if(Lit[j]==1)
  25. ++D[i];
  26. if(Lit[j]>1)
  27. {
  28. D[i]=0;
  29. break;
  30. }
  31. }
  32. }
  33. int Max=0,t=0;
  34. for(int i=1;i<=nr;++i)
  35. if(D[i]>Max)
  36. t=i,Max=D[i];
  37. if(Max<2)
  38. cout<<-1<<'\n';
  39. else
  40. cout<<cuv[t]<<'\n';
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement