题解 | 明明的随机数

明明的随机数

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 );*/

    }
}

全部评论

相关推荐

永不遗忘:才这么点算什么拉黑,我初筛连着挂几十次了,最后还是能进面
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务