论文网
English Papers
万事OK网
发表论文
 
 首页 > IT文章 > 程序设计 >
用C语言编程递归求行列式的值

[科技论文网] http://www.scipapers.com    2007-12-02  

    用C语言编程递归求行列式的值

    /************************************************************************
    功能: 用递归方法求行列式的值
    作者: 黄志斌 于 广西河池
    在自学《高等数学(二)》时,做行列式习题所得结果有些与教材所附
    答案不一致,为了验证究竟答案的正确性,编写了这个程序。
    其实用MS Office中Excel也可以验证,不过自己 DIY  感觉更舒服。
        希望这个程序能对您有所帮助。
    日     期     概  要
    -----------------------------------------------------
    2001.3.23     完成运算功能
    2002.3.17     按照匈牙利式命名规则和
                  林锐博士的《高质量C/C++编程指南》
                  增强程序可读性
    2002.3.19     停止使用全局变量iRowOrCol,
                  将原先的调试部分改为预处理
    *********************************************************************/
    #include "stdio.h"
    #include "mem.h"
    #define IsDebug 0

    /*int iRowOrCol;*/
    void ReadMatrix(int *ipMatrixRead, int iRowOrCol4Read)
    {
     int iRow4Read, iCol4Read;
     for (iRow4Read = 0; iRow4Read < iRowOrCol4Read; iRow4Read ++)
     {
      for (iCol4Read = 0; iCol4Read < iRowOrCol4Read; iCol4Read ++)
      {
       printf("matrix[%d, %d]=", iRow4Read, iCol4Read);
       scanf("%d", (ipMatrixRead + iRow4Read * iRowOrCol4Read + iCol4Read));
      }
     }
    }


    void WriteMatrix(int *ipMatrixWrite, int p_iRowOrCol)
    {
     int iRow4Write, iCol4Write;
     putch('┌');

     for (iRow4Write = 0; iRow4Write < (p_iRowOrCol + 1) * 3 - 1; iRow4Write ++)
     {
      putch(' ');
     }
     printf("%c\n", '┐');

     for (iRow4Write = 0; iRow4Write < p_iRowOrCol; iRow4Write ++)
     {
      putch('│');
      for (iCol4Write = 0; iCol4Write < p_iRowOrCol; iCol4Write ++)
      {
       printf("%3d", *(ipMatrixWrite + iRow4Write * p_iRowOrCol + iCol4Write));
      }
      printf("%c\n", '│');
     }

     putch('└');
     for (iRow4Write = 0; iRow4Write < (p_iRowOrCol + 1) * 3 -1; iRow4Write ++)
     {
      putch(' ');
     }
     printf("%c\n", '┘');

     #if IsDebug == 1
      getch();
     #endif
    }


    int ComputMatrix(int *ipMatrixComput, int iColComput)
    {
     int iRow4Comput, iCol4Comput, iRowTmp, *ipNewMatrix, CurrentRow, iResult;

     if (1 == iColComput)
     {
      iResult = *ipMatrixComput;
     }
     else
     {
      iResult = 0;
      for (CurrentRow = 0; CurrentRow < iColComput; CurrentRow ++)
      {
       if (*(ipMatrixComput + CurrentRow * iColCom! put))
       {
        if (ipNewMatrix = (int *)malloc((iColComput - 1) * (iColComput - 1) * sizeof(int)))
        {
         #if IsDebug == 1
          printf("\n%d", *(ipMatrixComput + CurrentRow * iColComput));
         #endif

         for (iRowTmp = 0, iRow4Comput = 0; iRow4Comput < iColComput; iRow4Comput ++)
         {
          if (iRow4Comput != CurrentRow)
          {
           for (iCol4Comput = 0; iCol4Comput < iColComput -1; iCol4Comput ++)
           {
            *(ipNewMatrix + iRowTmp*(iColComput - 1) + iCol4Comput) = *(ipMatrixComput + iRow4Comput * iColComput + iCol4Comput + 1);
           }
           iRowTmp ++;
          }
         }

         #if IsDebug == 1
          for (iRow4Comput = 0; iRow4Comput < iColComput - 1; iRow4Comput ++)
          {
           for (iCol4Comput = 0; iCol4Comput < iColComput - 1; iCol4Comput ++)
           {
            printf(" %d ", *(ipNewMatrix + iRow4Comput * (iColComput - 1) + iCol4Comput));
           }
          }    来源:

声明:本文由网友推荐或作者提交,版权归原作者所有,刊登此文仅为传播知识,展示研究成果,提高文章引用率。未经原作者授权,禁止用于任何形式的商业行为。科技论文网倡导尊重知识、尊重劳动、保护原创、知识共享。由于部分论文文章来于网络,文章作者不祥,请相关的原创作者与我们联系,以便加上您的署名。

1 2 下一页  
用C语言编程递归求行列式的值
下面没有链接了     CRC算法与实现
最新论文
·[程序设计]用C语言编程递归求行列式的值
·[程序设计]CRC算法与实现
·[程序设计]Base64算法详解和实现
·[程序设计]查找算法集(数组实现、链表实现)
·[程序设计]质数填表问题的回溯算法
·[程序设计]拓朴排序算法实现
·[程序设计][数值算法]线性方程组的求解---迭代法小结
·[程序设计]完全三叉树解决长方形容器中光源反射点遍历的问题
·[程序设计]动态规划求解最长公共子串问题
·[程序设计]最小生成树kruskal算法
 
 

搜索论文

Google
论文分类

论文网 论文发表网 论文 免费论文网 找论文网 毕业论文 中国论文网 英语论文 百度论文 聘教网 易搜
 免费发布论文    中国论文网 2008版权所有  业务联系:pinjiao@126.com