Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- //Vkarvame dumite
- List<string> words = new List<string>();
- for (int i = 0; i < n; i++) {
- string enteredWord = Console.ReadLine();
- words.Add(enteredWord);
- }
- //Razmestvame
- for (int i = 0; i < words.Count; i++) {
- int pos = words[i].Length % (n + 1);
- if (pos < words.Count) {
- string currentWord = words[i];
- words.Remove(words[i]);
- words.Insert(pos, currentWord);
- }
- }
- //Izchisliavame dyljinata na naj dylgata duma
- int bestLenght = int.MinValue;
- string strToCheck = " ";
- for (int i = 0; i < words.Count; i++)
- {
- strToCheck = words[i];
- if (strToCheck.Length > bestLenght)
- {
- bestLenght = strToCheck.Length;
- }
- }
- //Pravim vsichki taka
- for (int i = 0; i < words.Count; i++)
- {
- string currentWord = words[i];
- for (int j = 0; j <= bestLenght; j++)
- {
- if (currentWord.Length < j)
- {
- currentWord += "#";
- }
- }
- words[i] = currentWord;
- }
- //Pochvame da syzdavame magicheskata duma
- int f = 0;
- string wordToCheck = " ";
- string magicWord = "";
- for (int i = 0; i < bestLenght; i++) {
- for (int j = 0; j < words.Count; j++) {
- wordToCheck = words[j];
- if (wordToCheck[f] != '#') {
- magicWord += wordToCheck[f];
- }
- }
- f++;
- }
- Console.WriteLine(magicWord);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement