Created
January 20, 2018 09:28
-
-
Save ugurozturk/352711537d9a6480fa2e3e7f8830b9e4 to your computer and use it in GitHub Desktop.
Gets random number lists to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
namespace cekilis | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("How many numbers you want ?"); | |
int adet = Convert.ToInt32(Console.ReadLine()); | |
List<int> items = new List<int>(); | |
for (int i = 0; i < adet; i++) | |
{ | |
Random r = new Random(); | |
int s = r.Next(adet); | |
if (!items.Contains(s)) | |
{ | |
items.Add(s); | |
Console.WriteLine(items.Count + " : " + s); | |
} | |
else | |
{ | |
i--; | |
} | |
} | |
StreamWriter sw = new StreamWriter("numbers.txt",true); | |
foreach (int sayi in items) | |
{ | |
sw.WriteLine(sayi); | |
} | |
sw.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment