Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Lab01Disc
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> Universal = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- List<int> A = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
- List<int> B = new List<int>() { 5, 6, 7, 8, 9, 10 };
- List<int> C = new List<int>() { 1, 2, 3, 8, 9, 10 };
- List<int> AC;
- List<int> ACB;
- AC = A.Intersect(C).ToList();
- ACB = AC.Union(B).ToList();
- var amount3 = Universal.Count - 1;
- Console.Write("Даны множества:\nU = {");
- foreach (int i in Universal)
- {
- if (amount3 != Universal.IndexOf(i))
- {
- Console.Write($"{i}, ");
- }
- else
- {
- Console.Write(i + "}");
- }
- }
- var amount4 = A.Count - 1;
- Console.WriteLine();
- Console.Write("A = {");
- foreach (int i in A)
- {
- if (amount4 != A.IndexOf(i))
- {
- Console.Write($"{i}, ");
- }
- else
- {
- Console.Write(i + "}");
- }
- }
- var amount5 = B.Count - 1;
- Console.WriteLine();
- Console.Write("B = {");
- foreach (int i in B)
- {
- if (amount5 != B.IndexOf(i))
- {
- Console.Write($"{i}, ");
- }
- else
- {
- Console.Write(i + "}");
- }
- }
- var amount6 = C.Count - 1;
- Console.WriteLine();
- Console.Write("C = {");
- foreach (int i in C)
- {
- if (amount6 != C.IndexOf(i))
- {
- Console.Write($"{i}, ");
- }
- else
- {
- Console.Write(i + "}");
- }
- }
- Console.WriteLine();
- Console.WriteLine("Первое выражение: ");
- Console.Write("(A ∩ C) ∪ B = {");
- var amount1 = ACB.Count - 1;
- foreach (int i in ACB)
- {
- if (amount1 != ACB.IndexOf(i)){
- Console.Write($"{i}, ");
- }
- else{
- Console.Write(i + "}");
- }
- }
- Console.WriteLine();
- int[] arrB = { 5, 6, 7, 8, 9, 10 };
- int[] arrC = { 1, 2, 3, 8, 9, 10 };
- List<int> BC = new List<int>();
- for (int i = 0; i < arrB.Length; i++){
- if(arrB[i] != arrC[i] && arrC[i] != arrB[i]){
- BC.Add(arrB[i]);
- BC.Add(arrC[i]);
- }
- }
- BC.Sort();
- var amount2 = BC.Count - 1;
- Console.WriteLine("Выражение выражение: ");
- Console.Write("B ∆ C = {");
- foreach (int i in BC){
- if (amount2 != BC.IndexOf(i))
- {
- Console.Write($"{i}, ");
- }
- else
- {
- Console.Write(i + "}");
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment