Generation

generate functionSun, 18 Jun 2023

The output is the n x m matrix that is drawn with the symbols (┘ ┌ └ ┐ ─ │ / ┼), fulfilling the condition that if the matrix is square and odd then a cross is drawn in its center. Example: Input 5 5 Output ┌───┐ │ │ │ │─┼─│ │ │ │ └───┘

def cross(n, m): #insert your code here for i in range(1, n+1): for j in range(1, m+1): if i == 1: if j == 1: print('┌', end='') elif j == m: print('┐', end='') elif j == m//2 + 1: print('┬', end='') else: print('─', end='') elif i == n: if j == 1: print('└', end='') elif j == m: print('┘', end='') elif j == m//2 + 1: print('┴', end='') else: print('─', end='') elif i == n//2 + 1: if j == 1: print('├', end='') elif j == m: print('┤', end

Questions about programming?Chat with your personal AI assistant