解题思路:
一共有8种情况。
cubes = [[6,7,2,1,5,9,8,3,4],
[8,3,4,1,5,9,6,7,2],
[2,9,4,7,5,3,6,1,8],
[6,1,8,7,5,3,2,9,4],
[2,7,6,9,5,1,4,3,8],
[4,3,8,9,5,1,2,7,6],
[8,1,6,3,5,7,4,9,2],
[4,9,2,3,5,7,8,1,6]
]
参考代码:
mapL = [list(map(int,input().split())) for _ in range(3)] cubes = [[6,7,2,1,5,9,8,3,4], [8,3,4,1,5,9,6,7,2], [2,9,4,7,5,3,6,1,8], [6,1,8,7,5,3,2,9,4], [2,7,6,9,5,1,4,3,8], [4,3,8,9,5,1,2,7,6], [8,1,6,3,5,7,4,9,2], [4,9,2,3,5,7,8,1,6] ] cube = [] r = [] for i in mapL: for j in i: cube.append(j) for i in range(8): flag = True for j in range(9): if cube[j] != cubes[i][j] and cube[j] != 0: flag = False break if flag: r.append(i) if len(r) == 1: for i in range(9): print(cubes[r[0]][i],end=" ") if (i+1)%3 == 0: print() else: print("Too Many")
0.0分
2 人评分
C语言程序设计教程(第三版)课后习题8.6 (C++代码)浏览:763 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:741 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:561 |
【蟠桃记】 (C语言代码)浏览:710 |
字符串问题 (C语言代码)浏览:1634 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:768 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:388 |
杨辉三角 (C语言代码)浏览:504 |
数列问题 (C语言代码)浏览:1068 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:841 |