[Training] Blue Bridge Cup Day 1263

1263

[Blue Bridge Cup 2015 preliminary round] X Large Print

Xiaoming desired piece together with an asterisk, to print out a large X, he can be required to control the width and height of the entire character stroke.
To facilitate alignment of space are all the empty space with a period character instead.
Requires two input integers mn, it represents the height of the pen width, X's.
Input
a plurality of sets of data inputs
each set of test data input line, comprising two integers, separated by a space
(0 <m <n, 3 <n <1000, to ensure that n is an odd)
output
requires a large-output X
sample input the Copy
. 3 . 9
. 4 21 is
sample output Copy

note

no

algorithm

  1. Using an array of numbers corresponding to the symbols
  2. You can use symmetric simplify, modify traverse this question I first pass a good array
  3. Traversing the second pass output pattern

answer

def display(data):
    for i in range(len(data)):
        for j in range(len(data[i])):
            if data[i][j]:
                print('*',end='')
            else:
                print('.',end='')
        print()
while True:  
    m, n = map(int,input().split())      
    array = [[0 for i in range(m+n-1)] for i in range(n)]
    v = [1 for i in range(m)]
    for i in range(n):
        array[i][i:i+m] = v
        array[i][n-1-i:n-1-i+m] = v # 左右对称
    display(array)
while True:        
    print(f(input()))

Guess you like

Origin www.cnblogs.com/yanshanbei/p/12216070.html