哇终于AC了,很多细节需要注意。python确实方便啊

回复帖子

@WNLJOKER 2019-04-29 10:19 回复

仅供参考 python3

# CONSTANT
LINE_NUM = 4
ALPHABET_LEN = 26
ASCII_START = 65    # chr(65) = 'A'

# the map (letter -> occur_time)  
dict_map = {}
for i in range (ALPHABET_LEN):
    dict_map[chr(ASCII_START+i)] = 0

# read the input
read_input = []
for this_line in range(LINE_NUM):
    read_input.append(input().split())

# record data in the dict
# what a beautiful langrage
for this_line in read_input:
    for this_word in this_line:
        for this_letter in this_word:
            if this_letter in dict_map:
                dict_map[this_letter] += 1

# plot the figure
longest_stars = dict_map[max(dict_map, key=dict_map.get)]
star_num = longest_stars
this_line_star = [' ']*(ALPHABET_LEN*2 - 1)   # empty line
while(star_num >= 1):
    for this_letter in dict_map:  # check each elem in dict_map
        if dict_map[this_letter] == star_num:    # print a '*', data--
            dict_map[this_letter] -= 1
            this_line_star[(ord(this_letter) - ASCII_START)*2] = '*'
    for elem in this_line_star:        
        print(elem, end = '')
    star_num -= 1
    print('\n', end = '')

# print the last line
for i in range(ALPHABET_LEN - 1):
    print(chr(ASCII_START + i), end = ' ')
print('Z', end = '')
反馈
如果你认为某个帖子有问题,欢迎向洛谷反馈,以帮助更多的同学。



请具体说明理由,以增加反馈的可信度。