vencinachev

Files

Dec 2nd, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace GerryTutor
  9. {
  10.     class Program
  11.     {
  12.  
  13.         static List<double> Union(List<double> a, List<double> b)
  14.         {
  15.             List<double> result = new List<double>();
  16.             foreach (var item in a)
  17.             {
  18.                 if (!result.Contains(item))
  19.                 {
  20.                     result.Add(item);
  21.                 }
  22.             }
  23.             foreach (var item in b)
  24.             {
  25.                 if (!result.Contains(item))
  26.                 {
  27.                     result.Add(item);
  28.                 }
  29.             }
  30.             return result;
  31.         }
  32.         static List<int> NonRepeat(int[] arr)
  33.         {
  34.             HashSet<int> set = new HashSet<int>();
  35.             foreach (var item in arr)
  36.             {
  37.                 set.Add(item);
  38.             }
  39.             return set.ToList();
  40.         }
  41.         static void Main(string[] args)
  42.         {
  43.             /* Ex 8
  44.              * string filename = Console.ReadLine();
  45.             if (File.Exists(filename))
  46.             {
  47.                 using (StreamReader reader = new StreamReader(filename))
  48.                 {
  49.                     string line;
  50.                     int cnt = 0;
  51.                     while ((line = reader.ReadLine()) != null)
  52.                     {
  53.                         cnt++;
  54.                     }
  55.                     Console.WriteLine($"Lines count: {cnt}");
  56.                 }
  57.             }
  58.             else
  59.             {
  60.                 Console.WriteLine("File not found!");
  61.             }*/
  62.             HashSet<string> namesset = new HashSet<string>();
  63.             using (StreamReader reader = new StreamReader("rats.txt"))
  64.             {
  65.                 string line;
  66.                 while ((line = reader.ReadLine()) != null)
  67.                 {
  68.                     namesset.Add(line);
  69.                 }
  70.             }
  71.  
  72.             using (StreamWriter writer = new StreamWriter("out.txt"))
  73.             {
  74.                 foreach (var item in namesset)
  75.                 {
  76.                     writer.WriteLine(item);
  77.                 }
  78.                 Console.WriteLine("Writed....");
  79.             }
  80.  
  81.         }
  82.     }
  83. }
  84.  
Add Comment
Please, Sign In to add comment