Advertisement
nyker

Untitled

Apr 13th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class LongestInArr
  4. {
  5. static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8. int count = 0;
  9. int bestcount = 0;
  10. string container = "";
  11. List<string> strList = new List<string>();
  12. for (int i = 0; i < n; i++)
  13. {
  14. strList.Add(Console.ReadLine());
  15. }
  16. for (int i = 0; i < strList.Count; i++)
  17. {
  18. for (int j = 0; j < strList.Count; j++)
  19. {
  20. if (j + 1 <= strList.Count)
  21. {
  22. if (strList[i] == strList[j])
  23. {
  24. count++;
  25. }
  26. else
  27. {
  28. if (count > bestcount)
  29. {
  30. bestcount = count;
  31. count = 0;
  32. if (container != strList[i])
  33. {
  34. container = "";
  35. container += strList[i];
  36. }
  37. }
  38. else
  39. {
  40. count = 0;
  41. }
  42. }
  43. }
  44. }
  45. }
  46. Console.WriteLine(bestcount);
  47. for (int i = 0; i < bestcount; i++)
  48. {
  49. Console.WriteLine(container);
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement