File tree 3 files changed +65
-18
lines changed
3 files changed +65
-18
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,20 @@ public static void Main(string[] args)
9
9
{
10
10
UnoDimensional < int > unoInt = new ( 5 ) ;
11
11
unoInt . Add ( 1 ) ;
12
- unoInt . Add ( 1 ) ;
12
+ unoInt . Add ( 123 ) ;
13
13
unoInt . Add ( 1 ) ;
14
14
unoInt . Add ( 1 ) ;
15
15
unoInt . Add ( 1000 ) ;
16
16
unoInt . Print ( ) ;
17
+
17
18
unoInt . Reverse ( ) ;
18
19
unoInt . Print ( ) ;
19
20
21
+ unoInt . Sorting ( ) ;
22
+ unoInt . Print ( ) ;
23
+
24
+ Console . WriteLine ( string . Join ( "," , unoInt . Where ( x => x > 1 ) ) ) ;
25
+
20
26
// int[] numbers = unoInt.Where( (x) => {});
21
27
// Console.WriteLine(string.Join(' ', numbers));
22
28
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -43,31 +43,47 @@ public void Add(T element)
43
43
_array [ _size ++ ] = element ;
44
44
}
45
45
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 ( )
47
63
{
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
50
69
{
51
- if ( _arr [ i ] == element )
70
+ for ( int i = 0 ; i < ( newArray . Length / 2 ) ; i ++ )
52
71
{
53
- continue ;
72
+ count = newArray [ i ] ;
73
+ newArray [ i ] = newArray [ newArray . Length - i - 1 ] ;
74
+ newArray [ newArray . Length - i - 1 ] = count ;
54
75
}
55
- _arr [ i ] = _array [ i ] ;
76
+ return newArray ;
77
+ }
78
+ catch
79
+ {
80
+ return _array ;
56
81
}
57
- Array . Resize ( ref _arr , _arr . Length - 1 ) ;
58
- return _arr ;
59
82
}
60
83
61
-
62
- public T [ ] Reverse ( )
84
+ public void Sorting ( )
63
85
{
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 ) ;
71
87
}
72
88
73
89
public override void Print ( )
You can’t perform that action at this time.
0 commit comments