Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- /*20 40 10 10 30 80
- 25 20 40 30 10
- output 10 20 25 30 40 80*/
- class JoinNumbers
- {
- static void Main()
- {
- List<string> listOne = new List<string>(Console.ReadLine().Split(' '));
- List<string> listTwo = new List<string>(Console.ReadLine().Split(' '));
- List<string> joinNumbers = RemoveOccurNumbers(listOne);
- joinNumbers = UnionAllNumber(joinNumbers,listTwo);
- joinNumbers.Sort();
- Console.WriteLine("Now numbers are sorted!");
- foreach (string i in joinNumbers)
- {
- Console.Write(i + " ");
- }
- Console.WriteLine();
- }
- static List<string> UnionAllNumber(List<string> joinNumbers, List<string> listTwo)
- {
- foreach (string i in listTwo)
- {
- if(!joinNumbers.Contains(i))
- {
- joinNumbers.Add(i);
- }
- }
- return joinNumbers;
- }
- static List<string> RemoveOccurNumbers(List<string> listOne)
- {
- List<string> union = new List<string>();
- foreach (string item in listOne)
- {
- if(union.Contains(item))
- {
- continue;
- }
- union.Add(item);
- }
- return union;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment