显示方阵的非对角线元素必须满足的条件是什么。例如,
L=123
456
789
答案应该是以下形式:
3
5
7
答案 0 :(得分:1)
>>> l = len(matrix[0])
所有行都有相同的长度:
>>> [matrix[l-1-i][i] for i in range(l-1,-1,-1)]
[3, 5, 7]
您希望遍历列表,从第一行开始并获取其第三个元素,然后是第二行的第二个元素,依此类推:
// Create Controller
var popoverContent = CustomPop()
// Get NavController
var nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.Popover
// Get PopoverPresentationController
var popover = nav.popoverPresentationController as UIPopoverPresentationController
popover.sourceView = self.view
popover.sourceRect = CGRectMake(100,100,0,0)
// Show Popover
self.presentViewController(nav, animated: true, completion: nil)
答案 1 :(得分:0)
我已经从上面的答案中得到了提示并且说得对,我猜。
n=input('Enter the no. of rows=')
a=[[0 for j in range(n)]for i in range(n)]
for i in range(n):
for j in range(n):
a[i][j]=input()
print'\nInput Matrix is->'
for i in range(n):
for j in range(n):
print a[i][j],' ',
print
print'\nOff-diagonal elements are->'
for i in range(n):
for j in range(n):
if i+j==n-1:
print a[i][j],
else: print ' ',
print