题解 | 明明的随机数
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
public class Program { public static void Main() { string count = System.Console.ReadLine(); bool[] numbers = new bool[1000]; string line; while ((line = System.Console.ReadLine()) != null) { if (!numbers[int.Parse(line)]) { numbers[int.Parse(line)] = true; } } for (int i = 0; i < numbers.Length; i++) if (numbers[i]) System.Console.WriteLine(i); /* int n = 0; string line; while ((line = System.Console.ReadLine()) != null) { // 注意 while 处理多个 case n = int.Parse(line); int[] a = new int[1000]; for (int i = 0; i < n; i++) { var num = int.Parse(System.Console.ReadLine()); a[ num ] = 1; } for (int i = 0; i < 1000; i++) { if (a[i] == 1) System.Console.WriteLine(i); } }*/ /*System.Collections.Generic.SortedSet<int> list = new System.Collections.Generic.SortedSet<int>(); int count = 0; int first = 0; string line; while ((line = System.Console.ReadLine()) != null) { // 注意 while 处理多个 case if (first == 0) { count = int.Parse(line); first++; } else { list.Add(int.Parse(line)); if (first == count) break ; first++; } } foreach (int i in list) System.Console.WriteLine( i );*/ } }