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
49
50
51
52
53
54
55
56
57
58
59
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace MechCoding
{
public static class Coder
{
public static string Codieren(string source)
{
List<string> Ausgabe = new List<string>();
Random ran = new Random();
foreach (var item in source.Split(' '))
{
if (item.Count() <=3)
{
Ausgabe.Add(item);
continue;
}
char first = item[0];
char last = item[item.Count() - 1];
char[] list = new char[item.Count() - 2];
string alpha = item.Remove(0, 1);
alpha = alpha.Remove(alpha.Count() - 1, 1);
foreach (var item2 in alpha )
{
int ini;
bool tr = true;
while (tr)
{
ini = ran.Next(0,alpha.Count());
if (list[ini] == '\0')
{
list[ini] = item2;
tr = false;
}
}
}
string fertig = "";
fertig += first;
foreach (var item2 in list)
{
fertig += item2;
}
fertig += last;
Ausgabe.Add(fertig);
}
string Fertig = "";
foreach (var item in Ausgabe)
{
Fertig += item + " ";
}
return Fertig;
}
}
}
|