forked from NataSola/HelloCode
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (45 loc) · 952 Bytes
/
Copy pathProgram.cs
File metadata and controls
53 lines (45 loc) · 952 Bytes
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
void FillArray(int[] collection)
{
int length = collection.Length;
int index = 0;
while (index < length)
{
collection[index] = new Random().Next(1, 10);
//index = index + 1;
index++;
}
}
void PrintArray(int[] col)
{
int count = col.Length;
int position = 0;
while (position < count)
{
Console.WriteLine(col[position]);
position++;
}
}
int IndexOf(int[] collection, int find)
{
int count = collection.Length;
int index = 0;
int position = -1;
while (index < count)
{
if (collection[index] == find)
{
position = index;
break;
}
index++;
}
return position;
}
int[] array = new int[10];
FillArray(array);
array[4] = 4;
array[6] = 4;
PrintArray(array);
Console.WriteLine();
int pos = IndexOf(array, 444);
Console.WriteLine(pos);