⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).htm

📁 高性能计算高斯消去解方程组c++程序(复杂度 n^3
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="97%">
  <TBODY>
  <TR>
    <TD bgColor=#000000 height=24 width=1></TD>
    <TD bgColor=#f2f8ff>
      <TABLE bgColor=#f2f8ff cellPadding=4 cellSpacing=0 width="100%">
        <TBODY>
        <TR>
          <TD bgColor=#f2f8ff rowSpan=2 vAlign=top width=178><IMG height=4 
            src="" width=0><BR>
            <TABLE border=0 cellPadding=0 cellSpacing=0>
              <TBODY>
              <TR>
                <TD width=30>&nbsp;<IMG alt=该用户目前不在线 height=15 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/offline1.gif" 
                  width=15></TD>
                <TD>
                  <TABLE 
                    style="FILTER: glow(color=#996699,direction=135)">&nbsp;<FONT 
                    color=#ffffff><B>海阔天空</B></FONT>&nbsp;
                    <TBODY></TBODY></TABLE></TD>
                <TD> <IMG alt=哦,帅哥哟 height=14 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/mal.gif" 
                  width=20> <IMG alt=此人为版主 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/teammo.gif" 
                  width=16></TD></TR></TBODY></TABLE>&nbsp;<FONT color=#555555>头衔: 
            论坛版主<BR></FONT>&nbsp;<FONT color=#333333></FONT> <BR>&nbsp; <IMG 
            height=90 src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/4_1472.gif" 
            width=74> <BR>&nbsp;<IMG height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/pips4.gif" width=100> 
            <BR>&nbsp;<FONT color=#555555>威望: 0</FONT> <BR>&nbsp;<FONT 
            color=#333333>级别: <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/lookinfo.cgi?action=style" 
            target=_blank>精灵王</A></FONT> <BR>&nbsp;<FONT color=#555555>来自: 安徽合肥 
            </FONT><BR>&nbsp;<FONT color=#333333>鉴定: 已设置保密</FONT> 
            <BR>&nbsp;<FONT color=#555555>魅力: <IMG alt=3921 height=8 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/bar4.gif" 
            width=20></FONT> <BR>&nbsp;<FONT color=#333333>经验: <IMG alt=100 
            height=8 src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/bar5.gif" 
            width=1></FONT> <BR>&nbsp;<FONT color=#555555>金钱: 5413 雷傲元</FONT> 
            <BR>&nbsp;<FONT color=#333333>总发贴数: <B>378</B> 篇</FONT> 
            <BR>&nbsp;<FONT color=#555555>注册日期: 2004/02/02</FONT><BR><IMG 
            height=4 src="" width=0><BR></TD>
          <TD bgColor=#f2f8ff height="100%" rowSpan=2 width=1>
            <TABLE bgColor=#90c8ff cellPadding=0 cellSpacing=0 height="100%" 
            width=1>
              <TBODY>
              <TR>
                <TD width=1></TD></TR></TBODY></TABLE></TD>
          <TD bgColor=#f2f8ff height="100%" vAlign=top width=*><IMG height=4 
            src="" width=0><BR>&nbsp;<A 
            href="javascript:openScript('messanger.cgi?action=new&amp;touser=海阔天空',420,320)" 
            title=给海阔天空发送一个短消息><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/message.gif" 
            width=16>消息</A> <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/profile.cgi?action=show&amp;member=海阔天空" 
            title=查看海阔天空的个人资料><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/profile.gif" 
            width=16>查看</A> <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/search.cgi?action=startsearch&amp;TYPE_OF_SEARCH=username_search&amp;NAME_SEARCH=topictitle_search&amp;FORUMS_TO_SEARCH=4&amp;SEARCH_STRING=海阔天空" 
            target=_blank title=搜索海阔天空在本分论坛的全部贴子><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/find.gif" 
            width=16>搜索</A> <A 
            href="javascript:openScript('friendlist.cgi?action=adduser&amp;adduser=海阔天空',420,320)" 
            title=加海阔天空为我的好友><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/friend.gif" 
            width=16>好友</A> <A href="mailto:ahzhming@163.com" title=电子邮件地址><IMG 
            border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/email.gif" 
            width=16>邮件</A> <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/post.cgi?action=copy1&amp;forum=4&amp;topic=1462&amp;postno=1" 
            title=复制这个贴子><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/copy.gif" 
            width=16>复制</A> <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/post.cgi?action=replyquote&amp;forum=4&amp;topic=1462&amp;postno=1" 
            title=引用回复这个贴子><IMG border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/reply.gif" 
            width=16>引用</A> <A 
            href="http://www.lasg.ac.cn/cgi-bin/forum/post.cgi?action=reply&amp;forum=4&amp;topic=1462"><IMG 
            alt=回复贴子 border=0 height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/replynow.gif" 
            width=16>回复</A> <BR>
            <HR color=#000000 SIZE=1 width="100%">

            <TABLE cellPadding=0 cellSpacing=0 style="TABLE-LAYOUT: fixed" 
            width="100%">
              <TBODY>
              <TR>
                <TD vAlign=top width=32><IMG height=13 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/00.gif" 
                  width=13>&nbsp;</TD>
                <TD 
                style="LEFT: 0px; LETTER-SPACING: 0pt; LINE-HEIGHT: 130%; WIDTH: 100%; WORD-WRAP: break-word"><FONT 
                  color=#555555><FONT color=#555555><BR><BR>#include 
                  &lt;iostream&gt; <BR>#include &lt;fstream&gt; <BR>#include 
                  &lt;iomanip&gt; <BR>#include &lt;cmath&gt; <BR>#include 
                  &lt;algorithm&gt; <BR><BR>using namespace std; 
                  <BR><BR>ifstream fin("guass.in"); <BR><BR>#define NN 100 
                  <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 
                  &nbsp; &nbsp;g是系数巨阵n*n,b是增广向量n, <BR>double 
                  g[NN][NN],b[NN],x[NN]; &nbsp; &nbsp;// &nbsp; &nbsp;x是方程组的解n维。 
                  <BR>int n; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 
                  &nbsp;下标一律以零开始计算。 <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; // <BR>bool guass(); &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; 
                  &nbsp;guass()函数对以上参数进行求解方程组 <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp;并将结果放入x中。 <BR><BR>void 
                  outg(); <BR>void in(); <BR><BR>int main() <BR>{ <BR>&nbsp; 
                  fin&gt;&gt;n; <BR>&nbsp; in(); <BR>&nbsp; if (!guass()) 
                  cout&lt;&lt;"No solution!"&lt;&lt;endl; <BR>&nbsp; &nbsp; 
                  &nbsp;else{ <BR>&nbsp; &nbsp; &nbsp; &nbsp; for (int 
                  i=0;i&lt;n;i++) <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp;cout&lt;&lt;"x [ "&lt;&lt;i&lt;&lt;" ]= 
                  "&lt;&lt;x&lt;&lt;endl; <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  cout&lt;&lt;endl; <BR>&nbsp; &nbsp; &nbsp; &nbsp; } 
                  <BR><BR><BR>&nbsp; getchar(); <BR>&nbsp; fin.close(); 
                  <BR>&nbsp; return 0; <BR>} <BR>void in() <BR>{ <BR>&nbsp; int 
                  i,j; <BR>&nbsp; for (i=0;i&lt;n;i++) &nbsp;{ <BR>&nbsp; &nbsp; 
                  &nbsp;for (j=0;j&lt;n;j++) <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  fin&gt;&gt;g[j]; <BR>&nbsp; &nbsp; &nbsp;fin&gt;&gt;b; 
                  <BR>&nbsp; &nbsp; &nbsp;} <BR>&nbsp; return; <BR><BR>} 
                  <BR><BR>bool guass() <BR>{ <BR>&nbsp; int i,j,k,p; <BR>&nbsp; 
                  int flag[NN]; <BR>&nbsp; double l; <BR>&nbsp; 
                  memset(flag,0,sizeof(flag)); <BR><BR>&nbsp; for 
                  (i=0;i&lt;n;i++){ <BR>&nbsp; &nbsp; &nbsp;p=-1; <BR>&nbsp; 
                  &nbsp; &nbsp;for (j=0;j&lt;n;j++) <BR>&nbsp; &nbsp; &nbsp; 
                  &nbsp; if (!flag[j]) <BR>&nbsp; &nbsp; &nbsp; &nbsp; if 
                  (fabs(g[j]-0.0)&gt;1e-8) <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp;if (p==-1) p=j; <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; else <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if 
                  (fabs(g[p])+1e-8&lt;=fabs(g[j])) p=j; <BR>&nbsp; &nbsp; 
                  &nbsp;cout&lt;&lt;"p="&lt;&lt;p&lt;&lt;endl; <BR>&nbsp; &nbsp; 
                  &nbsp;flag[p]=1; <BR>&nbsp; &nbsp; &nbsp;if (p==-1) return 
                  false; <BR>&nbsp; &nbsp; &nbsp;for (j=0;j&lt;n;j++) <BR>&nbsp; 
                  &nbsp; &nbsp; &nbsp; if (p!=j){ <BR>&nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp;l=g[j]/g[p]; <BR>&nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp;for (k=i;k&lt;n;k++) <BR>&nbsp; &nbsp; 
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g[j][k]-=g[p][k]*l; 
                  <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b[j]-=b[p]*l; 
                  <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} <BR>&nbsp; 
                  &nbsp; &nbsp; outg(); <BR>&nbsp; &nbsp; &nbsp;} <BR><BR>&nbsp; 
                  for (i=0;i&lt;n;i++) <BR>&nbsp; &nbsp; &nbsp;for 
                  (j=0;j&lt;n;j++) <BR>&nbsp; &nbsp; &nbsp; &nbsp; if 
                  (fabs(g[j]-0.0)&gt;1e-8){ <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp;x[j]=b/g[j]; <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  &nbsp; &nbsp;break; <BR>&nbsp; &nbsp; &nbsp; &nbsp; } 
                  <BR>&nbsp; return true; <BR><BR>} <BR><BR>void outg() <BR>{ 
                  <BR>&nbsp; int i,j; <BR>&nbsp; cout.setf(ios::fixed); 
                  <BR>&nbsp; cout.precision(2); <BR>&nbsp; &nbsp;for 
                  (i=0;i&lt;n;i++){ <BR>&nbsp; &nbsp; &nbsp;for (j=0;j&lt;n;j++) 
                  <BR>&nbsp; &nbsp; &nbsp; &nbsp; 
                  cout&lt;&lt;setw(8)&lt;&lt;g[j]; <BR>&nbsp; &nbsp; 
                  &nbsp;cout&lt;&lt;setw(8)&lt;&lt;b; <BR>&nbsp; &nbsp; 
                  &nbsp;cout&lt;&lt;endl; <BR>&nbsp; &nbsp; &nbsp;} <BR>&nbsp; 
                  return; <BR><BR>} <BR><BR>-- 
                  <TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
                    <TBODY>
                    <TR>
                      <TD><BR><BR>------------------------------------------------------------------------------------<BR>与人方便,与己方便。<BR>学得越多,问题越多;为别人解决的问题越多,自己学的东西也越多。<BR>寻找Genetic 
                        Programming爱好者。</TD></TR></TBODY></TABLE><BR></FONT></FONT></TD>
                <TD width=16></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD bgColor=#f2f8ff class=bottomline vAlign=bottom>
            <HR color=#000000 SIZE=1 width="100%">

            <TABLE cellPadding=0 cellSpacing=0 width="100%">
              <TBODY>
              <TR>
                <TD vAlign=bottom><FONT color=#555555>&nbsp;<A 
                  href="http://www.lasg.ac.cn/cgi-bin/forum/postings.cgi?action=edit&amp;forum=4&amp;topic=1462&amp;postno=1" 
                  title=编辑这个贴子><IMG border=0 height=15 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/edit.gif" 
                  width=16>编辑</A> <A 
                  href="http://www.lasg.ac.cn/cgi-bin/forum/postings.cgi?action=directdel&amp;forum=4&amp;topic=1462&amp;postno=1" 
                  title=删除这个回复><IMG align=absMiddle border=0 height=16 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/a_delete.gif" 
                  width=52></A> <IMG alt=发贴时间 height=15 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/posttime.gif" 
                  width=16>2004/04/27 10:36am <IMG alt="" height=15 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/ip.gif" 
                  width=13>IP: 已设置保密</FONT></TD>
                <TD align=right vAlign=bottom width=110 nowarp></TD></FORM>
                <TD align=right vAlign=bottom width=4></TD></TR></TBODY></TABLE><IMG 
            height=4 src="" width=0><BR></TD></TR></TBODY></TABLE></TD>
    <TD bgColor=#000000 height=24 width=1></TD></TR></TBODY></TABLE>
<TABLE align=center bgColor=#000000 border=0 cellPadding=0 cellSpacing=0 
width="97%">
  <TBODY>
  <TR>
    <TD height=1></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="97%">
  <TBODY>
  <TR>
    <TD bgColor=#000000 height=24 width=1></TD>
    <TD bgColor=#e8f4ff>
      <TABLE bgColor=#e8f4ff cellPadding=4 cellSpacing=0 width="100%">
        <TBODY>
        <TR>
          <TD bgColor=#e8f4ff rowSpan=2 vAlign=top width=178><IMG height=4 
            src="" width=0><BR>
            <TABLE border=0 cellPadding=0 cellSpacing=0>
              <TBODY>
              <TR>
                <TD width=30>&nbsp;<IMG alt=该用户目前不在线 height=15 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/offline1.gif" 
                  width=15></TD>
                <TD>
                  <TABLE 
                    style="FILTER: glow(color=#996699,direction=135)">&nbsp;<FONT 
                    color=#ffffff><B>ustcsunl</B></FONT>&nbsp;
                    <TBODY></TBODY></TABLE></TD>
                <TD> <IMG alt=哦,帅哥哟 height=14 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/mal.gif" 
                  width=20> <IMG alt=此人为版主 
                  src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/teammo.gif" 
                  width=16></TD></TR></TBODY></TABLE>&nbsp;<FONT color=#555555>头衔: 
            论坛版主<BR></FONT>&nbsp;<FONT color=#333333></FONT> <BR>&nbsp; <IMG 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/69-1.gif"> 
            <BR>&nbsp;<IMG height=16 
            src="『 高性能计算 』 - 高斯消去解方程组c++程序(复杂度 n^3).files/pips5.gif" width=100> 
            <BR>&nbsp;<FONT color=#555555>威望: +1</FONT> <BR>&nbsp;<FONT 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -