Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
39
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 <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ifstream read("bac.txt");
  9.  
  10. int n=0, a;
  11. while (!read.eof())
  12. {
  13. read>>a;
  14. n++;
  15. }
  16. read.clear();
  17. read.seekg(0, read.beg);
  18. int edd[n];
  19. for (int w1=0; w1<=n; w1++)
  20. {
  21. edd[w1]=1;
  22. }
  23.  
  24. int num, elozo;
  25. read>>a;
  26. num=a;
  27. int s;
  28. for(s=1; !read.eof(), s<=n; elozo=a)
  29. {
  30. read>>a;
  31. if (a==elozo)
  32. {
  33. edd[s]++;
  34. }
  35. else
  36. {
  37. s++;
  38. }
  39. if (edd[s]>edd[s-1])
  40. {
  41. num=a;
  42. }
  43. }
  44. int maxim=0;
  45. for (int h=0; h<=s; h++)
  46. {
  47. if (edd[h]>maxim)
  48. {
  49. maxim=edd[h];
  50. }
  51. }
  52. cout << maxim << endl;
  53. for (int k=1; k<=maxim; k++)
  54. {
  55. cout<< num <<" ";
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement