-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (31 loc) · 1 KB
/
Copy pathProgram.cs
File metadata and controls
41 lines (31 loc) · 1 KB
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
Console.Write("Введите элементы массива через запятую: ");
string input = Console.ReadLine()!;
string[] inputArray = input.Split(',');
string[] resultArray = FilterArrayByLength(inputArray);
Console.WriteLine("Результирующий массив:");
foreach (string item in resultArray)
{
Console.WriteLine(item);
}
static string[] FilterArrayByLength(string[] inputArray)
{
int count = 0;
for (int i = 0; i < inputArray.Length; i++)
{
if (inputArray[i].Length <= 3)
{
count++;
}
}
string[] resultArray = new string[count];
int index = 0;
for (int i = 0; i < inputArray.Length; i++)
{
if (inputArray[i].Length <= 3)
{
resultArray[index] = inputArray[i];
index++;
}
}
return resultArray;
}