题解 | 将向量转换为对角矩阵
将向量转换为对角矩阵
https://www.nowcoder.com/practice/fa80e7e3e07345b1993b93f46182643b
import numpy as np
def make_diagonal(x):
return np.diag(x)
if __name__ == "__main__":
x = np.array(eval(input()),dtype=np.float16)
print(make_diagonal(x))
查看5道真题和解析