题解 | #明明的随机数#
明明的随机数
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 ;
}
}
} }