题解 | #明明的随机数#

明明的随机数

http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

using System; using System.Collections.Generic; namespace app { public class test { public static void Main() { string num; List list = new List(); while ((num = Console.ReadLine()) != null) { int n = int.Parse(num); callBack(list, n); foreach (int cur in list) { Console.WriteLine(cur); } } }

public static void callBack(List<int> list, int num) {
    if (num > 0) {
        string current;
        while ((current = Console.ReadLine()) != null) {
            num--;
            int c = int.Parse(current);
            if (!list.Contains(c)) {
                list.Add(c);
            }
            callBack(list, num);
        }
    } else {
        list.Sort();
        return ;
    }

}

} }

全部评论

相关推荐

06-07 00:00
已编辑
腾讯_后端开发
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务