| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 734 人关注过本帖
标题:[原创]大家看看这程序怎样
只看楼主 加入收藏
soup312
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-3-13
收藏
 问题点数:0 回复次数:4 
[原创]大家看看这程序怎样

//这程序是实现多个距阵相乘的次数最少 using System;

namespace ConsoleMinMaxtic { class Class1 { public static int min(int[] r,int n,ref int b) {int j=0,i=0,k=0,d=0; int [,]c=new int [n,n]; for(i=0;i<n;i++) c[i,i]=0; for(d=1;d<n;d++) for( i=0;i<n-d;i++) {j=i+d; c[i,j]=1000000; for(k=i+1;k<=j;k++) { if(c[i,j]>(c[i,k-1]+c[k,j]+r[i]*r[k]*r[j+1])) c[i,j]=c[i,k-1]+c[k,j]+r[i]*r[k]*r[j+1]; } b=k-1; } return c[0,n-1];

} [STAThread] static void Main(string[] args) { int n=0; int i=0,b=0; int m=0;//记最小的次数 int[] r=new int [10]; Console.WriteLine("输入矩阵的个数N:",n); n=Int32.Parse(Console.ReadLine()); Console.WriteLine("输入n个矩阵行,最后一个数为最后一矩阵的列"); for(i=0;i<=n;i++) { Console.Write("r("+i+")="); r[i]=Int32.Parse (Console.ReadLine ());

} m=min(r,n,ref b);//b Console.WriteLine ("最小的次数:{0}"+"划分地点:{1}",m,b); Console.ReadLine(); // // TOD 在此处添加代码以启动应用程序 // } } } //希望大家评价一下 给个程序编写的意见,谢谢

搜索更多相关主题的帖子: public 
2005-04-16 12:36
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
次数最少是什么意思?
2005-04-16 12:48
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
基本上说,老实说。
我看不懂

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-16 14:06
soup312
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-3-13
收藏
得分:0 
意思就是如何选择使得距阵乘法次数最少,比如:距阵a*b*c是选择(a*b)*c还是a*(b*c)呢这样求乘法的次数。知道了吗?
2005-04-17 08:54
tianhe
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2005-3-17
收藏
得分:0 
不太好使,不明白干什么用的。没有注释要别人怎么看。

-------------------------------------------- 朴素,清醒
2005-04-18 15:24
快速回复:[原创]大家看看这程序怎样
数据加载中...
 
   



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

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