Skip to content

Instantly share code, notes, and snippets.

@ugurozturk
Created January 20, 2018 09:28
Show Gist options
  • Save ugurozturk/352711537d9a6480fa2e3e7f8830b9e4 to your computer and use it in GitHub Desktop.
Save ugurozturk/352711537d9a6480fa2e3e7f8830b9e4 to your computer and use it in GitHub Desktop.
Gets random number lists to file
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