Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02.Worm_Ipsum
- {
- class Program
- {
- static void Main(string[] args)
- {
- var inputLine = Console.ReadLine();
- var result = new List<string>();
- while (inputLine != "Worm Ipsum")
- {
- var line = inputLine.Split(new[] {'.'},StringSplitOptions.RemoveEmptyEntries);
- if (line.Length==1)
- {
- var lineValid = inputLine.Split(new[] {' ','.','-'}, StringSplitOptions.RemoveEmptyEntries);
- foreach (var word in lineValid)
- {
- var curentWord = "";
- char curentChar;
- var maxCounter = 0;
- for (int i = 0; i < word.Length; i++)
- {
- var counter = 0;
- var index = word.IndexOf(word[i]);
- while (index !=-1)
- {
- counter++;
- index = word.IndexOf(word[i], index + 1);
- }
- if (counter>=2 && maxCounter < counter)
- {
- curentChar = word[i];
- maxCounter = counter;
- for (int j = 0; j < word.Length; j++)
- {
- curentWord += curentChar;
- }
- }
- }
- if (curentWord !="")
- {
- result.Add(curentWord);
- }
- else
- {
- result.Add(word);
- }
- }
- Console.WriteLine(string.Join(" ",result)+".");
- }
- result.Clear();
- inputLine = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement