Skip to content

Commit 78e720a

Browse files
committed
obeme
1 parent a4e3a05 commit 78e720a

File tree

3 files changed

+65
-18
lines changed

3 files changed

+65
-18
lines changed

task4.1/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ public static void Main(string[] args)
99
{
1010
UnoDimensional<int> unoInt = new(5);
1111
unoInt.Add(1);
12-
unoInt.Add(1);
12+
unoInt.Add(123);
1313
unoInt.Add(1);
1414
unoInt.Add(1);
1515
unoInt.Add(1000);
1616
unoInt.Print();
17+
1718
unoInt.Reverse();
1819
unoInt.Print();
1920

21+
unoInt.Sorting();
22+
unoInt.Print();
23+
24+
Console.WriteLine(string.Join(",", unoInt.Where(x => x > 1)));
25+
2026
// int[] numbers = unoInt.Where( (x) => {});
2127
// Console.WriteLine(string.Join(' ', numbers));
2228
}

task4.1/task4.1.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34221.43
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "task4.1", "task4.1.csproj", "{7608AAF0-D359-4517-A38A-A6DB5D5A506E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7608AAF0-D359-4517-A38A-A6DB5D5A506E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7608AAF0-D359-4517-A38A-A6DB5D5A506E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7608AAF0-D359-4517-A38A-A6DB5D5A506E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7608AAF0-D359-4517-A38A-A6DB5D5A506E}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {ADED004A-CBFD-4573-AECD-18F868354426}
24+
EndGlobalSection
25+
EndGlobal

task4.1/uno.cs

+33-17
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,47 @@ public void Add(T element)
4343
_array[_size++] = element;
4444
}
4545

46-
public T[] Remove(T element)
46+
//public T[] Remove(T element)
47+
//{
48+
// T[] _arr = new T[_array.Length - 1];
49+
// for (int i = 0; i < _arr.Length; i++)
50+
// {
51+
// if (_arr[i] == element)
52+
// {
53+
// continue;
54+
// }
55+
// _arr[i] = _array[i];
56+
// }
57+
// Array.Resize(ref _arr, _arr.Length - 1);
58+
// return _arr;
59+
//}
60+
61+
62+
public T[] Reverse()
4763
{
48-
T[] _arr = new T[_array.Length - 1];
49-
for (int i = 0; i < _arr.Length; i++)
64+
T[] newArray = new T[_capacity];
65+
newArray = _array;
66+
T count = default(T);
67+
68+
try
5069
{
51-
if (_arr[i] == element)
70+
for (int i = 0; i < (newArray.Length / 2); i++)
5271
{
53-
continue;
72+
count = newArray[i];
73+
newArray[i] = newArray[newArray.Length - i - 1];
74+
newArray[newArray.Length - i - 1] = count;
5475
}
55-
_arr[i] = _array[i];
76+
return newArray;
77+
}
78+
catch
79+
{
80+
return _array;
5681
}
57-
Array.Resize(ref _arr, _arr.Length - 1);
58-
return _arr;
5982
}
6083

61-
62-
public T[] Reverse()
84+
public void Sorting()
6385
{
64-
T[] _arr = new T[_array.Length];
65-
int count = 0;
66-
for (int i = _arr.Length; i >= 0; i--)
67-
{
68-
_arr[i] = _array[count++];
69-
}
70-
return _arr;
86+
Array.Sort(_array);
7187
}
7288

7389
public override void Print()

0 commit comments

Comments
 (0)