Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Files_for_cw
- {
- using System;
- using System.IO;
- internal class Program
- {
- private static Random rnd = new Random();
- public static void Main(string[] args)
- {
- do
- {
- string path = @"../../../input.txt";
- int N = ReadN();
- try
- {
- using (StreamWriter stream = new StreamWriter(path))
- {
- for (int i = 0; i < N; i++)
- {
- stream.WriteLine(rnd.Next(0, 1000));
- }
- } // using
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
- Console.WriteLine("Нажмите любую клавишу, чтобы повторить или Эскейп, чтобы выйти.");
- } while (Console.ReadKey(true).Key != ConsoleKey.Escape);
- }
- private static int ReadN()
- {
- Console.WriteLine("Введите количество чисел:");
- int N;
- while (!int.TryParse(Console.ReadLine(), out N))
- {
- Console.WriteLine("Попробуйте еще разок:");
- }
- return N;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement