由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
CS版 - 求助:关于2个python的题目
相关主题
CS Algo Question关于markov decision process求解的复杂度 (转载)
Python也支持functional programmingCS Journal审稿机会 (转载)
Python: index out of rang errorRe: Help!Cable internet connectivity pro
哪位大哥帮忙找一篇paper,(Gennery 92)one algorithm question
线性不等式组.windows 7 蓝屏求助
求教高手:超级难题求解CS Algorithm question
need help: two dimensional image processingLatex怎么调整公式的长度啊
how to find a clusterAn algorihmic question
相关话题的讨论汇总
话题: numberlist话题: function话题: list话题: column话题: make
进入CS版参与讨论
1 (共1页)
k*****6
发帖数: 26
1
有python比较熟练的朋友帮忙看下这两道题吗?万分感激。。
Do both of these problems using at least one loop each and not using any
special pre-existing functions that give you the answer with just one line
of code.
1. Make a function to count the number of times a specified number is
repeated in a list/array. That means that if we have a number list
numberList=[5, 12, 0, 7, 2, 5, 10, 9, 12, 5];
and we use the function call
numRepeats(numberList, 5)
we get the output: 3 --- meaning 5 occurs three times in numberList.
2. Make a function that takes in a multi-dimensional array/list and returns
the "diagonal" --- a list of the elements at the 1st row-and-1st column, 2nd
row-and-2nd column, 3rd row-and-3rd column, etc. That means if we have a
multi-dimensional array:
multiArray = [[3, -4, 12, 5], [5, 2, 11, -5], [2, 2, 0, 5], [-5, -3, 2, 2]
];
and we use the function call
diagonal(multiArray)
we get the output [3, 2, 0, 2] .
1 (共1页)
进入CS版参与讨论
相关主题
An algorihmic question线性不等式组.
c 程序超过32位怎么办?求教高手:超级难题求解
[转载] CS interview questionneed help: two dimensional image processing
Please help, an algorithem questionhow to find a cluster
CS Algo Question关于markov decision process求解的复杂度 (转载)
Python也支持functional programmingCS Journal审稿机会 (转载)
Python: index out of rang errorRe: Help!Cable internet connectivity pro
哪位大哥帮忙找一篇paper,(Gennery 92)one algorithm question
相关话题的讨论汇总
话题: numberlist话题: function话题: list话题: column话题: make