-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
28 lines (23 loc) · 789 Bytes
/
Program.cs
File metadata and controls
28 lines (23 loc) · 789 Bytes
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
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Encryption {
class Program {
public static void Encryption(string s) {
string trimmedString = Regex.Replace(s, @"\s+", "");
int columns = (int)Math.Ceiling(Math.Sqrt(trimmedString.Length));
for (int i = 0; i < columns; i++) {
var counter = 0;
while (i + (counter * columns) < trimmedString.Length) {
Console.Write(trimmedString[i + (counter * columns)]);
counter++;
}
Console.Write(' ');
}
}
static void Main(string[] args) {
string s = Console.ReadLine();
Encryption(s);
}
}
}