| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1434 人关注过本帖
标题:Maple程序改写python
只看楼主 加入收藏
yyn0452
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-13
收藏
 问题点数:0 回复次数:0 
Maple程序改写python
Maple:
Cr := proc( x::integer, n::list(integer) ) option remember;
    t := add(i,i=n);
if min(op(n)) < 0 or x < 0 or x > t or x > 2*(t-max(op(n))) + 1 then 0
elif x=0 then     if nops(n) <= 1 or max(op(2..-1,n))=0 then 1
else 0 fielse ns2 := n[2..-1];     ns3 := sort(ns2);     
while nops(ns3) > 0 and ns3[1] = 0 do ns3 := subsop(1=NULL,ns3) od;     
if ns3 <> ns2 then RETURN( Cr(x,[n[1],op(ns3)]) )     
elif x < nops(ns3) then RETURN(0)
     elif x = nops(ns3) then RETURN( mul(i!,i=n) * nops(ns3)! / t! )
     fi;
     r := n[1]/t * Cr( x, subsop(1=n[1]-1,n) );
     for i from 2 to nops(n) do if n[i] > 0
then         r := r + n[i]/t * Cr( x-1, subsop( 1=n[i]-1, i=n[1], n ))
     fi od;     
r
fiend:

图片附件: 游客没有浏览图片的权限,请 登录注册


求高手改成python版的,我写了一部分,运行有错。。求指点
搜索更多相关主题的帖子: max remember python Maple 
2012-04-05 16:24
快速回复:Maple程序改写python
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020616 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved