#!/usr/bin/python # -*- coding: utf-8 -*- def z94(): #斐波那契数列 def filie(x): a,b,t=1,1,0 if x==1 or x==2:return 1 while t!=x-2: a,b,t=b,a+b,t+1 return b for i in range(1,30): print filie(i) def z95(): #把三位数字转化成罗马数字 def lm(x): fy=[["","C"
[Python练习题 028] 求一个3*3矩阵对角线元素之和 ----------------------------------------------------- 这题解倒是解出来了,但总觉得代码太啰嗦.矩阵这东西,应该有个很现成的方法可以直接计算才对-- 啰嗦代码如下: str = input('请输入9个数字,用空格隔开,以形成3*3矩阵:') n = [int(i) for i in str.split(' ')] #获取9个数字 mx = [] #存储矩阵 for i in ra
Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Note: The total