The time limit :1.0s Memory limit :256.0MB
The use of letters can form some beautiful graphics , Here is an example :
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC
This is a 5 That's ok 7 The graph of the column , Please find out the law of this figure , And output a n That's ok m The graph of the column .
The input line , Contains two integers n and m, The number of columns representing the number of rows of the graph you want to output .
Output n That's ok , Every m Characters , For your graphics .
5 7
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC
1 <= n, m <= 26.
a,b=map(int,input().split()) #map() Map the specified sequence according to the provided function ,input().split() Enter multiple values at the same time. The data type is str
list1=[[0 for n in range(26)] for m in range(26)]
list2=[[0 for n in range(b)] for m in range(a)]
for n in range(26):
for m in range(26):
if m<n:
list1[n][m]=ord('A')+n-m
else:
list1[n][m]=ord('A')+m-n
for i in range(a):
for x in range(b):
list2[i][x]=list1[i][x]
print(chr(list2[i][x]),end=' ')
print()
list2=[[0 for n in range(b)] for m in range(a)]
Where the front bracket represents the column , The following parentheses represent the line
That is to create a Line contains b A list of elements
26 Let's use... First ord The function converts it to its corresponding ASCII value
Use after addition and subtraction chr Function restore
a=ord('A')
print(a)
b=chr(a)
print(b)
ord() Function return type is int type
You can add and subtract
chr() Function and ord() The function works the opposite
There is no space between the letters in the output data in the title , It's easy to make mistakes
Source::Réseau1.Principe de ré
introduction : Refer to some o