Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class LongestAreaInArray
- {
- static void Main()
- {
- Console.Write("Please insert how many string will be read: ");
- int strCount = int.Parse(Console.ReadLine());
- string[] words = new string[strCount];
- for (int i = 0; i < words.Length; i++)
- {
- words[i] = Console.ReadLine();
- }
- string longestArea = "";
- int longestAreaLenght = 0;
- int currentLongest = 0;
- int repeats = 1;
- for (int startPos = 0; startPos < words.Length; startPos++)
- {
- repeats = 1;
- for (int endPos = startPos +1; endPos < words.Length; endPos++)
- {
- if (words[startPos]==words[endPos])
- {
- longestArea = words[startPos];
- repeats++;
- break;
- }
- }
- currentLongest += repeats;
- }
- Console.WriteLine(longestAreaLenght);
- for (int i = 0; i < longestAreaLenght; i++)
- {
- Console.WriteLine(longestArea);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement