fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string str;
  7. getline(cin, str);
  8. int longest=0;
  9. int length=0;
  10. string maxword, word;
  11. char x;
  12. for(int i=0; i<str.length(); i++)
  13. {
  14.  
  15. x=str[i+1];
  16. if(str[i]<=x)
  17. {
  18. length++;
  19. word+=str[i];
  20. }
  21. else
  22. {
  23. word+=str[i];
  24. if(length>longest)
  25. {
  26. longest=length;
  27. maxword=word;
  28. }
  29. length=0;
  30. word="";
  31. }
  32. }
  33. cout << maxword;
  34. return 0;
  35. }
Success #stdin #stdout 0s 3432KB
stdin
woimoepzbjvxfafpyfpzgmxugjodtemcjcpoxobfgbsmokkmcdpmawcwwaxhqwabzdlplvteszqgtkamxjkswkpnzpxpudxcmigz
stdout
bjvx