Advertisement
vencinachev

File

Nov 24th, 2020
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using java.util;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Diagnostics;
  9.  
  10. namespace SoftSvetlina
  11. {
  12.     class Program
  13.     {
  14.         static void Main()
  15.         {
  16.             List<int> nums = new List<int>();
  17.             using (StreamReader reader = new StreamReader("numbers.txt"))
  18.             {
  19.                 string line;
  20.                 while ((line = reader.ReadLine()) != null)
  21.                 {
  22.                     nums.Add(int.Parse(line));
  23.                 }
  24.             }
  25.  
  26.             nums.Sort();
  27.            
  28.             Console.WriteLine(string.Join(", ", nums));
  29.  
  30.             using (StreamWriter writer = new StreamWriter("numberssort.txt"))
  31.             {
  32.                 foreach (var item in nums)
  33.                 {
  34.                     writer.WriteLine(item);
  35.                 }
  36.             }
  37.  
  38.         }
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement