Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char s[256],v[]="aeiou";
  8. cin.getline(s,256);
  9. int lmax=0,pmax;
  10. for(int i=0;i<strlen(s)-1;++i)
  11. {
  12. for(int j=i+1;j<strlen(s);++j)
  13. if(s[i]==s[j])
  14. {
  15. int pi=i;
  16. int pj=j;
  17. while(s[pi]==s[pj] and s[pi]!=NULL and s[pj]!=NULL)
  18. {
  19. pi++;
  20. pj++;
  21. }
  22. int l=pi-i;
  23. if(l>lmax)
  24. {
  25. lmax=l;
  26. pmax=i;
  27. }
  28. else
  29. if(l==lmax)
  30. {
  31. if(s[pmax]>s[i])
  32. pmax=i;
  33. else
  34. if(s[i]==s[pmax])
  35. {
  36. int i1=pmax;
  37. int i2=i;
  38. while(s[i1]==s[i2] and s[i1]!=NULL and s[i2]!=NULL)
  39. {
  40. i1++;
  41. i2++;
  42. if(s[i1]>s[i2])
  43. pmax=i;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. for(int i=pmax;i<pmax+lmax;++i)
  50. cout<<s[i];
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement