Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include<vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. //Syzdavane vector i izpulvane sys stoinosti
  9. std::vector<int> V;
  10. int num;
  11.  
  12. cin >> num;
  13. for (int i = 0; i < num; i++)
  14. {
  15. int volue;
  16. cin >> volue;
  17. V.push_back(volue);
  18. }
  19.  
  20. int NumberRepet;
  21. int CounterRepet=1;
  22. int MaxCountRepet=1;
  23. for (int i = 0; i < num-1; i++)
  24. {
  25. if (V[i] == V[i + 1])
  26. {
  27.  
  28. CounterRepet++;
  29. if ((CounterRepet > MaxCountRepet)|| (CounterRepet > MaxCountRepet))
  30. {
  31. MaxCountRepet = CounterRepet;
  32. NumberRepet = V[i];
  33. }
  34.  
  35. }
  36. else
  37. {
  38. CounterRepet =1;
  39. }
  40.  
  41. }
  42.  
  43. if (MaxCountRepet == 1)
  44. {
  45. cout << V[num - 1];
  46. }
  47. else{
  48.  
  49. for(int j=0;j<MaxCountRepet;j++)
  50. cout << NumberRepet << " ";
  51. }
  52. }
  53.  
  54. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  55. // Debug program: F5 or Debug > Start Debugging menu
  56.  
  57. // Tips for Getting Started:
  58. // 1. Use the Solution Explorer window to add/manage files
  59. // 2. Use the Team Explorer window to connect to source control
  60. // 3. Use the Output window to see build output and other messages
  61. // 4. Use the Error List window to view errors
  62. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  63. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement