-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (39 loc) · 1.15 KB
/
Program.cs
File metadata and controls
40 lines (39 loc) · 1.15 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
using System;
namespace Ransomization
{
class Program
{
static void Main(string[] args)
{
//Counting unique random numbers upto 100 in an array.
int[] arr = new int[100];
bool addtoarray = true;
int k = 0, randomnumber;
Random r = new Random();
while(k < 100)
{
randomnumber = r.Next(1, 101);
addtoarray = true;
for(int l = 0; l < k; l++)
{
if(arr[l] == randomnumber)
{
addtoarray = false;
break;
}
}
if(addtoarray == true)
{
arr[k] = randomnumber;
k++;
}
}
Console.WriteLine("Length: {0}", arr.Length + Environment.NewLine);
foreach(int j in arr)
{
Console.Write("{0}, ", j);
}
Console.WriteLine(Environment.NewLine + Environment.NewLine);
}
}
}