Sveta 11th C#

 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Task 1");
string s1 = Console.ReadLine();
char[] s2 = s1.ToCharArray();
string letters_small = "a, b, c, d, e, f, g, h, i, k, l, m, n, o, p, q, r, s, t, v, x, y, z, j";
string letters_big = "A, B, C, D, E, F, G, H, I, K, L, M, N, O, P, Q, R, S, T, V, X, Y, Z, J";
string [] lett_s = letters_small.Split(' ', ',');
string [] lett_b = letters_big.Split(' ', ',');
lett_s = lett_s.Where(n => !string.IsNullOrEmpty(n)).ToArray();
lett_b = lett_b.Where(n => !string.IsNullOrEmpty(n)).ToArray();
for (int i = 0; i < s2.Length; i++)
{
for (int e = 0; e < lett_s.Length; e++)
{
if (Convert.ToString(s2[i]) == lett_s[e])
{
s2[i] = Convert.ToChar(lett_b[e]);
}
}
}
Console.WriteLine(s2);
Console.WriteLine("Task 2");
string s4, s5;
Console.WriteLine("First string");
s4 = Console.ReadLine();
Console.WriteLine("Second string");
s5 = Console.ReadLine();
int count = (s4.Length - s4.Replace(s5, "").Length) / s5.Length;
Console.WriteLine(count);
Console.ReadLine();
}
}
}