首页 > 试题广场 >

Simple Sorting

[编程题]Simple Sorting
  • 热度指数:5223 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.

输入描述:
For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.


输出描述:
For each case ,outtput file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.
示例1

输入

6
8 8 7 3 7 7

输出

3 7 8
while True:
    try:
        n=int(input().strip())
        inp=list(map(int,input().strip().split(' ')))
        #print(inp)
        inp=sorted(list(set(inp)))
        inp=list(map(str,inp))
        print(' '.join(inp))
    except:
        break
发表于 2019-08-04 13:06:42 回复(0)
while True:
    try:
        num,digits = int(input()),list(map(int,list(set(input().split()))))
        print(' '.join(map(str,sorted(digits))))
    except Exception:
        break
编辑于 2018-10-14 13:26:34 回复(0)

python3 solution:

while True:
    try:
        a,b=input(),map(int,input().split())
        print(" ".join(map(str,sorted(set(b)))))
    except:
        break
发表于 2017-10-06 15:58:41 回复(0)
try:
    while 1:
        n = input()
        print ' '.join(map(str, sorted(set(map(int, raw_input().split())))))
except:
    pass

发表于 2016-12-26 13:10:51 回复(0)

问题信息

难度:
4条回答 5576浏览

热门推荐

通过挑战的用户

查看代码