Advertisement
J00ker

Untitled

Jan 26th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. void Citire(char* s)
  8. {
  9. ifstream fin("sir.in");
  10. fin.getline(s, 99);
  11. fin.close();
  12. }
  13.  
  14. void Secv(char* s)
  15. {
  16. char secv[99], secvmx[99];
  17. int lg = -1, lgmx = -1;
  18.  
  19. for(int i = 0; s[i] != 0; i++)
  20. {
  21. if(s[i] <= s[i+1])
  22. {
  23. lg++;
  24. strncpy(secv+lg, s+i, 2);
  25. }
  26. else
  27. {
  28. if(lg > lgmx)
  29. {
  30. strcpy(secvmx, secv);
  31. lgmx = lg;
  32. }
  33. lg = -1;
  34. }
  35. }
  36. cout << lgmx << "\n";
  37. cout << secvmx;
  38. }
  39.  
  40.  
  41. int main()
  42. {
  43. char sir[99];
  44. Citire(sir);
  45. Secv(sir);
  46. cout << "\n";
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement