Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Problem2
- {
- using System;
- using System.Collections.Generic;
- using System.Text;
- class MagicWords
- {
- static void Main()
- {
- int numberOfWords = int.Parse(Console.ReadLine());
- string[] words = new string[numberOfWords];
- var upgradeWords = new List<string>();
- for (int i = 0; i < numberOfWords; i++)
- {
- string currentWord = Console.ReadLine();
- words[i] = currentWord;
- upgradeWords.Add(currentWord);
- }
- for (int i = 0; i < upgradeWords.Count; i++)
- {
- string currentWord = upgradeWords[i];
- int position = (upgradeWords[i].Length % (numberOfWords + 1));
- upgradeWords.Remove(upgradeWords[i]);
- upgradeWords.Insert(position,currentWord );
- }
- int maxLenght = 0;
- for (int i = 0; i < upgradeWords.Count; i++)
- {
- int currentLenght = upgradeWords[i].Length;
- if (currentLenght > maxLenght)
- {
- maxLenght = currentLenght;
- }
- }
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < maxLenght; i++)
- {
- for (int j = 0; j < upgradeWords.Count; j++)
- {
- if (upgradeWords[j].Length > i)
- {
- result.Append(upgradeWords[j][i]);
- }
- }
- }
- Console.WriteLine(result.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment