代码如下 为何输出结果什么也没有?
#include<stdio.h>
#define row 4
#define col 4
void main(void)
{
int det[row][col]={{1,2,3,4},{2,4,6,8},{2,0,4,6},{1,1,1,1}};
int r,c,i,flag=0,tmp=0;
for(r=1;r<row;r++)
for(i=0;det[r][0]!=0;i++)
if(0= =det[r][0]-det[0][0]*i)
for(c=0;c<col;c++)
det[r][c]-=det[0][c]*i;
for(r=1;r<row;r++)
{
if(flag= =3)
break;
for(c=1,flag=0;c<col;c++)
{
if(det[r][c]= =0)
flag++;
if(3= =flag)
{
for(c=1;c<row;c++)
tmp=det[r][c],det[r][c]=det[row-1][c],det[row-1][c]=tmp;
break;
}
}
}
for(r=2;r<row;r++)
{
if(det[r][1]>det[1][1])
for(c=1;c<col;c++)
tmp=det[r][c],det[r][c]=det[1][c],det[1][c]=tmp;
for(i=0;det[r][1]!=0;i++)
if(0= =det[r][1]-det[1][1]*i)
for(c=1;c<col;c++)
det[r][c]-=det[1][c]*i;
}
for(r=3;r<row;r++)
for(i=0;det[r][2]!=0;i++)
if(0= =det[r][2]-det[2][2]*i)
for(c=1;c<col;c++)
det[r][c]-=det[2][c]*i;
for(r=0;r<row;r++)
{
for(c=0;c<col;c++)
printf("%d “,det[r][c]);
printf(”\n");
}
}
C语言使矩阵经过初等变化变成上三角矩阵
最新推荐文章于 2024-03-03 18:56:32 发布