Using two characters: . (dot) and * (asterisk) print a frame-like pattern.
Input
You are given t - the number of test cases and for each of the test cases two positive integers: l - the number of lines and c - the number of columns of a frame.
Output
For each of the test cases output the requested pattern (please have a look at the example). Use one line break in between successive patterns.
Example
Input: 3 3 1 4 4 2 5 Output: * * * **** *..* *..* **** ***** *****主要 是python中的if语句的使用
代码如下
t = int(input())
for i in range(t):
line = input()
l = int(line.split(' ')[0])
c = int(line.split(' ')[1])
for j in range(l):
for k in range(c):
if j == 0 or j == l - 1:
print('*', sep='', end='')
elif k == 0 or k == c - 1:
print('*', sep='', end='')
else:
print('.', sep='',end='')
print()