python ITP1_6_C:官方House_codeShortVer_but_slow

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python ITP1_6_C:官方House_codeShortVer_but_slow相关的知识,希望对你有一定的参考价值。

# define
first = [[0 for i in range(10)] for j in range(3)]
second = [[0 for i in range(10)] for j in range(3)]
third = [[0 for i in range(10)] for j in range(3)]
forth = [[0 for i in range(10)] for j in range(3)]

# input
n = int(input())

datanum=n
info=[]

while n>0:
    info.append(list(map(int,input().split())))
    n -=1


def roomdata(x,f,r,v):
    x[f-1][r-1]+=v
        
for i in range(datanum):
    b=info[i][0]
    f=info[i][1]
    r=info[i][2]
    v=info[i][3]
    if b==1:
        roomdata(first,f,r,v)
    elif b==2:
        roomdata(second,f,r,v)
    elif b==3:
        roomdata(third,f,r,v)
    elif b==4:
        roomdata(forth,f,r,v)
        
# output
a = [first,second,third,forth]

def loop(x):    
    for i in range(3):
        print(" " + " ".join(map(str,x[i])))
    
for i in range(len(a)):
    loop(a[i])
    if i!=len(a)-1:
        print("#"*20)

以上是关于python ITP1_6_C:官方House_codeShortVer_but_slow的主要内容,如果未能解决你的问题,请参考以下文章

探索尝试:用OpenCV官方发布的build包替换Pip命令安装的Python包(以失败告终)

python动态模块导入

Python修行之路__流程控制

python FileNotFoundError: [WinError 2] 系统找不到指定的文件。

Python使用np.c_和np.r_实现数组转换成矩阵

Python-三元运算