-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMagicWords_solution01.cs
49 lines (47 loc) · 1.23 KB
/
MagicWords_solution01.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program
{
static void Main()
{
int Value = Int32.Parse(Console.ReadLine());
List<string> StrArray = new List<string>();
for (int i = 0; i < Value; i++)
{
StrArray.Add(Console.ReadLine());
}
for (int i = 0; i < Value; i++)
{
string CurrentString = StrArray[i];
int Index = CurrentString.Length % (Value + 1);
StrArray.Insert(Index, CurrentString);
if (Index < i)
{
StrArray.RemoveAt(i + 1);
}
else
{
StrArray.RemoveAt(i);
}
}
StringBuilder Result = new StringBuilder();
int MaxLength = 0;
foreach (var Str in StrArray)
{
MaxLength = Math.Max(MaxLength, Str.Length);
}
for (int i = 0; i < MaxLength; i++)
{
foreach (var Str in StrArray)
{
if (Str.Length > i)
{
Result.Append(Str[i]);
}
}
}
Console.WriteLine(Result.ToString());
}
}