C语言使矩阵经过初等变化变成上三角矩阵

代码如下 为何输出结果什么也没有?
#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");
}
}

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值