alexandrheathen

Untitled

Dec 2nd, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Lab01Disc
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> Universal = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  12.             List<int> A = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  13.             List<int> B = new List<int>() { 5, 6, 7, 8, 9, 10 };
  14.             List<int> C = new List<int>() { 1, 2, 3, 8, 9, 10 };
  15.             List<int> AC;
  16.             List<int> ACB;
  17.             AC = A.Intersect(C).ToList();
  18.             ACB = AC.Union(B).ToList();
  19.             var amount3 = Universal.Count - 1;
  20.             Console.Write("Даны множества:\nU = {");
  21.             foreach (int i in Universal)
  22.             {
  23.                 if (amount3 != Universal.IndexOf(i))
  24.                 {
  25.                     Console.Write($"{i}, ");
  26.                 }
  27.                 else
  28.                 {
  29.                     Console.Write(i + "}");
  30.                 }
  31.             }
  32.             var amount4 = A.Count - 1;
  33.             Console.WriteLine();
  34.             Console.Write("A = {");
  35.             foreach (int i in A)
  36.             {
  37.                 if (amount4 != A.IndexOf(i))
  38.                 {
  39.                     Console.Write($"{i}, ");
  40.                 }
  41.                 else
  42.                 {
  43.                     Console.Write(i + "}");
  44.                 }
  45.             }
  46.             var amount5 = B.Count - 1;
  47.             Console.WriteLine();
  48.             Console.Write("B = {");
  49.             foreach (int i in B)
  50.             {
  51.                 if (amount5 != B.IndexOf(i))
  52.                 {
  53.                     Console.Write($"{i}, ");
  54.                 }
  55.                 else
  56.                 {
  57.                     Console.Write(i + "}");
  58.                 }
  59.             }
  60.             var amount6 = C.Count - 1;
  61.             Console.WriteLine();
  62.             Console.Write("C = {");
  63.             foreach (int i in C)
  64.             {
  65.                 if (amount6 != C.IndexOf(i))
  66.                 {
  67.                     Console.Write($"{i}, ");
  68.                 }
  69.                 else
  70.                 {
  71.                     Console.Write(i + "}");
  72.                 }
  73.             }
  74.             Console.WriteLine();
  75.             Console.WriteLine("Первое выражение: ");
  76.             Console.Write("(A ∩ C) ∪ B = {");
  77.             var amount1 = ACB.Count - 1;
  78.             foreach (int i in ACB)
  79.             {
  80.                 if (amount1 != ACB.IndexOf(i)){
  81.                     Console.Write($"{i}, ");
  82.                 }
  83.                 else{
  84.                     Console.Write(i + "}");
  85.                 }
  86.             }
  87.             Console.WriteLine();
  88.             int[] arrB = { 5, 6, 7, 8, 9, 10 };
  89.             int[] arrC = { 1, 2, 3, 8, 9, 10 };
  90.             List<int> BC = new List<int>();
  91.             for (int i = 0; i < arrB.Length; i++){
  92.                 if(arrB[i] != arrC[i] && arrC[i] != arrB[i]){
  93.                     BC.Add(arrB[i]);
  94.                     BC.Add(arrC[i]);
  95.                 }
  96.             }
  97.             BC.Sort();
  98.             var amount2 = BC.Count - 1;
  99.             Console.WriteLine("Выражение выражение: ");
  100.             Console.Write("B ∆ C = {");
  101.             foreach (int i in BC){
  102.                 if (amount2 != BC.IndexOf(i))
  103.                 {
  104.                     Console.Write($"{i}, ");
  105.                 }
  106.                 else
  107.                 {
  108.                     Console.Write(i + "}");
  109.                 }
  110.             }
  111.             Console.ReadKey();
  112.         }
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment