Advertisement
Gesh4o

LongestArea

Oct 5th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class LongestAreaInArray
  5. {
  6. static void Main()
  7. {
  8. Console.Write("Please insert how many string will be read: ");
  9. int strCount = int.Parse(Console.ReadLine());
  10.  
  11. string[] words = new string[strCount];
  12.  
  13. for (int i = 0; i < words.Length; i++)
  14. {
  15. words[i] = Console.ReadLine();
  16. }
  17. string longestArea = "";
  18. int longestAreaLenght = 0;
  19. int currentLongest = 0;
  20. int repeats = 1;
  21.  
  22.  
  23. for (int startPos = 0; startPos < words.Length; startPos++)
  24. {
  25. repeats = 1;
  26. for (int endPos = startPos +1; endPos < words.Length; endPos++)
  27. {
  28. if (words[startPos]==words[endPos])
  29. {
  30. longestArea = words[startPos];
  31. repeats++;
  32. break;
  33. }
  34. }
  35. currentLongest += repeats;
  36. }
  37. Console.WriteLine(longestAreaLenght);
  38. for (int i = 0; i < longestAreaLenght; i++)
  39. {
  40. Console.WriteLine(longestArea);
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement