using System using System Collections Generic using System Linq using

 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
namespace ConsoleApplication2 {
class Program {
public static string isLetter = "Yo",
isStop = "Nice";
public static string readFile() {
string line, retValue = "";
StreamReader file = new StreamReader("C:\\Users\\evgeny\\Desktop\\67__kopia.result");
while ((line = file.ReadLine()) != null) {
retValue += line;
}
file.Close();
return retValue;
}
public static string ourCodedSong() {
string readingStr = readFile(),
retValue = "";
for (int i = 0; i < readingStr.Length; ++i) {
if (i + 2 < readingStr.Length && readingStr.Substring(i, 2) == isLetter)
retValue += isLetter + " ";
else if (i + 4 < readingStr.Length && readingStr.Substring(i, 4) == isStop) {
retValue += isStop + " ";
}
}
return retValue;
}
public static void can(string ourCodedSong) {
string ourSong = "";
int count = 96;
for (int i = 0; i < ourCodedSong.Length; ++i) {
if (i + 2 < ourCodedSong.Length && ourCodedSong.Substring(i, 2) == isLetter)
count++;
else if (i + 4 < ourCodedSong.Length && ourCodedSong.Substring(i, 4) == isStop) {
if (count > 96) ourSong += (char)count;
count = 96;
}
if (i + 9 < ourCodedSong.Length && ourCodedSong.Substring(i, 4) == isStop && ourCodedSong.Substring(i + 5, 4) == isStop) {
count = 96;
ourSong += " ";
}
}
StreamWriter file = new StreamWriter("C:\\Users\\evgeny\\Desktop\\result.txt");
file.WriteLine(ourSong);
file.Close();
}
static void Main(string[] args) {
can(ourCodedSong());
}
}
}