Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CSLight
- {
- internal class Program
- {
- static void Main()
- {
- const string CommandInputData = "1";
- const string CommandSumData = "2";
- const string CommandRestart = "3";
- List<string> lines = new List<string>();
- string[] firstArray = new string[0];
- string[] secondArray = new string[0];
- bool isWorking = true;
- Console.CursorVisible = false;
- while (isWorking)
- {
- if (lines.Count != 0)
- {
- OutputSum(lines);
- }
- if (firstArray.Length != 0)
- {
- OutputData(firstArray);
- Console.WriteLine("\n");
- OutputData(secondArray);
- Console.WriteLine("\n");
- }
- Console.WriteLine($"{CommandInputData} - Добавить данные");
- Console.WriteLine($"\n{CommandSumData} - Объединить данные");
- Console.WriteLine($"\n{CommandRestart} - Очистить данные");
- Console.Write("\nВведите команду: ");
- switch (Console.ReadLine())
- {
- case CommandInputData:
- InputData(ref firstArray, ref secondArray);
- break;
- case CommandSumData:
- SumNumbers(lines, firstArray);
- SumNumbers(lines, secondArray);
- break;
- case CommandRestart:
- firstArray = new string[0];
- secondArray = new string[0];
- lines.Clear();
- break;
- default:
- Console.WriteLine("\nТакой команды нет.");
- isWorking = false;
- break;
- }
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void InputData(ref string[] firstArray, ref string[] secondArray)
- {
- string[] tempFirstArray = new string[firstArray.Length + 1];
- string[] tempSecondArray = new string[secondArray.Length + 1];
- int minNumber = 0;
- int maxNumber = 10;
- Random rand = new Random();
- for (int i = 0; i < tempFirstArray.Length; i++)
- {
- tempFirstArray[i] = Convert.ToString(rand.Next(minNumber, maxNumber));
- tempSecondArray[i] = Convert.ToString(rand.Next(minNumber, maxNumber));
- }
- firstArray = tempFirstArray;
- secondArray = tempSecondArray;
- }
- static void SumNumbers(List<string> lines, string[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (lines.Contains(array[i]) == false)
- {
- lines.Add(array[i]);
- }
- }
- }
- static void OutputData(string[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write($"{array[i]} ");
- }
- }
- static void OutputSum(List<string> lines)
- {
- Console.Write("Сумма данных - ");
- foreach (var line in lines)
- Console.Write($"{line} ");
- Console.WriteLine("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement