Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用星型(*)Python转换的短路算法_Python_Sorting - Fatal编程技术网

使用星型(*)Python转换的短路算法

使用星型(*)Python转换的短路算法,python,sorting,Python,Sorting,一个名为fungsiIO的函数,它没有输入参数,用于将用户的输入更改为整数,该整数用空格分隔以打印星号(*)字符。这些星星从最小的(顶部)到最大的(底部)排序 注:仅一次输入命令/输入功能 我的代码: def fungsiIO(): pass #???? 运行/调用函数: fungsiIO() # example input 7 4 5 3 1 2 投入和预期产出: 7 4 5 3 1 2 * ** *** **** ***** ******* 非常感谢所有帮助我的

一个名为
fungsiIO
的函数,它没有输入参数,用于将用户的输入更改为整数,该整数用空格分隔以打印星号(*)字符。这些星星从最小的(顶部)到最大的(底部)排序

注:仅一次输入命令/输入功能


我的代码:

def fungsiIO():
    pass
    #????

运行/调用函数:

fungsiIO() # example input 7 4 5 3 1 2

投入和预期产出:

7 4 5 3 1 2
*
**
***
****
*****
*******


非常感谢所有帮助我的人

您需要使用
sorted()
这将按升序对您的数字进行排序

你可以读更多

def sol(nums):
对于排序中的i(nums):
打印(“*”*i,结束=“”)
打印()
溶胶([7,4,5,3,1,2])
输出: 这是解决办法

def fungsiIO():
    numbers = set(map(int, input().split())) 
    # if you enter 7 4 5 3 1 2 then
    # numbers will be {1, 2, 3, 4, 5, 7}, sorted and all unique.

    for num in numbers:
        print("*"*num,end='')
        print()


fungsiIO()

python 3或2?
我的代码
,代码在哪里?看不到任何东西!!在Python3中。。。。
def fungsiIO():
    numbers = set(map(int, input().split())) 
    # if you enter 7 4 5 3 1 2 then
    # numbers will be {1, 2, 3, 4, 5, 7}, sorted and all unique.

    for num in numbers:
        print("*"*num,end='')
        print()


fungsiIO()