| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 492 人关注过本帖
标题:想看一下吗?一个编程题,我不太懂,朋友帮我下好吗
只看楼主 加入收藏
默契哥哥
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-9-28
收藏
 问题点数:0 回复次数:1 
想看一下吗?一个编程题,我不太懂,朋友帮我下好吗
<用Doolittle分解求方阵的逆> 设A=LR,L为单位下三角阵,R为上三角阵,则A-1 =R-1 L-1,分别求出R-1和L-1,相乘即可得A-1。 (使用说明) 输入参数: N 方阵A(N,N)的阶数。 A(N,N) N阶方阵,按行存放。 输出参数: W 标志,W=0说明A非奇异,W=1表示A奇异,不存放A的逆。 D(N,N) 存放A的逆的元素。 中间工作单元: C(N,N) N阶方阵 (下面有VB的程序,麻烦帮我改改成PASCAL或者C好吗)
搜索更多相关主题的帖子: 朋友 
2005-09-28 18:54
默契哥哥
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-9-28
收藏
得分:0 
* 用Doolittle 分解求方阵的逆 * 30 '****************************************************** 50 Dim A(N, N), C(N, N), D(N, N) 60 Print Tan(3); "EG:"; Tab(8); "THE MATRIX A": Print 70 For I = 1 To N: For J = 1 To N 80 READ A(I, J): Print USING; "####.#"; A(I, J); 90 Next J: Print: Next I 100 Print: GoSub 300 110 Print Tab(5); "W="; W: Print 120 If W = 1 Then GoTo 190 130 Print Tab(15); "THE CONVERSE MATRIX OF A": Print 140 For I = 1 To N: For J = 1 To N 150 Print USING; "####.#####"; D(I, J);: Print " "; 160 Next J: Print: Next I 170 Data 1, 2, 3, 4, 1, 4, 9, 16, 1, 8, 27, 64, 1, 16, 81, 256 180 Data 190 End 300 '子程序' 310 '分解' 320 If A(1, 1) = 0 Then GoTo 890 330 For I = 2 To N: A(I, 1) = A(I, 1) / A(1, 1) 340 Next I 350 P = 0 360 For K = 2 To N: For J = K To N 370 For R = 1 To K - 1 380 P = P + A(K, R) * A(R, J) 390 Next R 400 A(K, J) = A(K, J) - P: P = 0 410 Next J 420 P = 0 430 For I = K + 1 To N: For R = 1 To K - 1 440 P = P + A(I, R) * A(R, K) 450 Next R 460 If A(K, K) = 0 Then GoTo 890 470 A(I, K) = (A(I, K) - P) / A(K, K): P = 0 480 Next I 490 Next K 500 For I = 1 To N: For J = 1 To I 510 If J = I Then C(I, I) = 1 520 If J <> I Then C(I, J) = A(I, J) 530 If J <> I Then A(I, J) = 0 540 Next J: Next I 550 '上三角求逆' 560 For K = N To 1 Step -1 570 If A(K, K) = 0 Then GoTo 890 580 A(K, K) = 1 / A(K, K) 590 For I = K - 1 To 1 Step -1 600 P = 0 610 For J = I + 1 To K 620 P = P - A(I, J) * A(J, K) 630 Next J 640 A(I, K) = P / A(I, I) 650 Next I 660 Next K 670 '下三角求逆' 680 For K = 1 To N: For I = K + 1 To N 690 P = 0 700 For J = I - 1 To K Step -1 710 P = P - C(I, J) * C(J, K) 720 Next J 730 C(I, K) = P / C(I, I) 740 Next I: Next K 750 '求A的逆' 760 For I = 1 To N: For J = I + 1 To N 770 C(I, J) = 0 780 Next J: Next I 790 For J = 1 To N: For I = J + 1 To N 800 A(I, J) = 0 810 Next I: Next J 820 For I = 1 To N: For J = 1 To N 830 D(I, J) = 0 840 For K = 1 To N 850 D(I, J) = D(I, J) + A(I, K) * C(K, J) 860 Next K 870 Next J: Next I 880 W = 0: Return 890 W = 1: Return
2005-09-28 18:55
快速回复:想看一下吗?一个编程题,我不太懂,朋友帮我下好吗
数据加载中...
 
   



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

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