Map使用python生成的图形中的最低点

u0sqgete  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(165)
data = input("Input:")

def parse_to_int(dat): # parse input data to int list
    individuals = dat.split(" ")
    num = []
    for individual in individuals:
        num.append((int)(individual))
    return num

def get_Max_and_MaxIndex_MinIndex(num_list): # get maximul value, its index and minimum value
    sign = 1
    val = 0
    max_val = 0
    min_val = 0
    max_ind = 0
    count = 0
    for num in num_list:
        count += 1
        val = val + sign * num
        sign = -1 * sign
        if (max_val < val):
            max_val = val
            max_ind = count
        if (min_val > val):
            min_val = val
    return max_val, max_ind, min_val

def sub_sum(ind): # calculate subsum until ind
    global num_input
    global subsum
    subsum = 0
    for i in range(ind + 1):
        subsum += num_input[i]
    return subsum

def sub_sum_with_sign(ind): # calculate subsum with sign until ind
    global num_input
    global subsum_withsign
    subsum_withsign = 0
    sign = 1
    for i in range(ind + 1):
        subsum_withsign += sign * num_input[i]
        sign = -1 * sign
    return subsum_withsign

def fill_data(ind): # fill data for print in empty data
    global print_data
    global cur_x
    global cur_y

    if ind % 2 == 0:
        str = '/'
        dx = 1
        dy = 1
    else:
        str = '\\'
        dx = 1
        dy = -1

    for _ in range(num_input[ind]):
        print_data[cur_y][cur_x] = str
        cur_x += dx
        cur_y += dy

    if ind % 2 == 0:
        cur_y -= 1
    else:
        cur_y += 1

    return print_data

# main program

num_input = parse_to_int(data)
col_num = 0 # column count
for elem in num_input:
    col_num += elem
max_min_num = get_Max_and_MaxIndex_MinIndex(num_input)
row_num = max_min_num[0] - max_min_num[2] # row count
start_num = 0
for i in range(max_min_num[1]):
    start_num += num_input[i] # maximum height element number
subsum = 0
subsum_withsign = 0
cur_x = 0
cur_y = -1 * max_min_num[2]

# start output

print("Output:\n")
print(" " * start_num + "o" + " " * (col_num - start_num))
print(" " * (start_num - 1) + "/|\\" + " " * (col_num - start_num - 1))
print(" " * (start_num - 1) + "< >" + " " * (col_num - start_num - 1))

# prepare data for print

print_data = []

for i in range(row_num):
    print_data.append([])
    for j in range(col_num):
        print_data[i].append(" ")

for ind in range(len(num_input)):
    fill_data(ind)

# print data

for indr in range(row_num - 1, -1, -1):
    print("".join(print_data[indr]))

上面的代码将给出此输出
在这段代码中,图形是使用python生成的,而不使用任何库。图表的最高点已标记。
我想标记图表的最低点,如下图所示。我完全不知道这件事。为了在生成的图形中标记最低尖端,应更改哪些值?
我是stackoverflow的新手,如果您需要更清晰的说明,请发表评论。。
如何在这里标出最低小费请帮我

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题