- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Hey, so I wanted to make a program for making a Matrix in Echelon form(Not Reduced Echelon Form). Everything seems to be working fine except when the last element of the matrix is 0. That time, it just divides the row and makes it 1! So, I added a while loop to fix that but it still doesn't work since the while loop is not getting executed! Could anyone tell me why?
#include <stdio.h>
#include <stdlib.h>
void Interchange(float A[][3],int row_pos,int column_pos,int m);
void RowDivide(float A[][3],int row_pos,int column_pos,int m);
void RowOperation(float A[][3],int row_pos,int row_op,int column_pos,int m);
int main()
{
int m;
printf("Enter the number of rows in the Matrix: ");
scanf("%d",&m);
float A[m][3];
printf("\nEnter the Matrix:\n");
for(int i=0 ; i<m ; i++)
{
for(int j=0 ; j<3 ; j++)
{
scanf("%f",&A[i][j]);
}
}
int column_pos=0;
for(int row_pos=0 ; row_pos<m ; row_pos++)
{
///For Interchanging
if(A[row_pos][column_pos] == 0)
{
Interchange(A,row_pos,column_pos,m);
}
///For Row Division
This While Loop doesn't get Executed!!! I know it's not getting executed cause it doesn't print "a" like I wrote Can anyone tell me as to why?!
while(A[row_pos][column_pos] == 0)
{
printf("a");
column_pos++;
}
RowDivide(A,row_pos,column_pos,m);
If the last element over here is 0, it divides it and makes it 1! Why?
///For Row Operations
if(row_pos == m-1)
{
break;
}
else
{
for(int row_op = row_pos+1 ; row_op<m ; row_op++)
RowOperation(A,row_pos,row_op,column_pos,m);
}
column_pos++;
}
printf("\nThe Matrix in Echolen Form:\n");
for(int i=0 ; i<m ; i++)
{
for(int j=0 ; j<3 ; j++)
{
printf("%0.2f ",A[i][j]);
}
printf("\n");
}
return 0;
}
void Interchange(float A[][3],int row_pos,int column_pos,int m)
{
float temp;
int cal_pos;
cal_pos=row_pos;
while(A[cal_pos][column_pos] == 0)
{
cal_pos++;
}
for(int i=row_pos ; i<row_pos+1 ; i++)
{
for(int j=column_pos ; j<3 ; j++)
{
temp = A[i][j];
A[i][j] = A[cal_pos][j];
A[cal_pos][j] = temp;
}
}
printf("\nThe Matrix after Interchanging Row %d is:\n",row_pos+1);
for(int i=0 ; i<m ; i++)
{
for(int j=0 ; j<3 ; j++)
{
printf("%0.2f ",A[i][j]);
}
printf("\n");
}
}
void RowDivide(float A[][3],int row_pos,int column_pos,int m)
{
float temp; ///To store the value of A[i][0] since it will get changed to 1 after dividing
for(int i=row_pos ; i<row_pos+1 ; i++)
{
temp = A[i][column_pos];
for(int j=0 ; j<3 ; j++)
{
A[i][j] = (A[i][j] / temp);
}
}
printf("\nThe Matrix after dividing the Row %d is:\n",row_pos+1);
for(int i=0 ; i<m ; i++)
{
for(int j=0 ; j<3 ; j++)
{
printf("%0.2f ",A[i][j]);
}
printf("\n");
}
}
void RowOperation(float A[][3],int row_pos,int row_op,int column_pos,int m)
{
float Cal_Operation; ///For the value of row that must be added
for(int i=row_op ; i<row_op+1 ; i++)
{
if(A[i][column_pos] == 0)
{
break;
}
else
{
Cal_Operation = -A[i][column_pos];
printf("\nCalculated Variable for Row %d= %0.2f\n",row_op+1,Cal_Operation);
for(int j=column_pos ; j<3 ; j++)
{
A[i][j] = A[i][j] + (Cal_Operation*A[row_pos][j]);
}
printf("The Matrix after Operating on Row %d is:\n",row_op+1);
for(int i=0 ; i<m ; i++)
{
for(int j=0 ; j<3 ; j++)
{
printf("%0.2f ",A[i][j]);
}
printf("\n");
}
}
}
}
最佳答案
我不确定你在做什么,但如果你希望 while 循环找到第一个 0 元素,你应该将其更改为:
while(A[row_pos][column_pos] != 0)
不过,我可能误解了您的意图,如果是这样,请告诉我。
关于C-制作梯形矩阵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41912603/
当你进入页面http://m.google.com使用 Mobile Safari,您会在页面顶部看到漂亮的栏。 我想像那样画一些梯形(美国:梯形),但我不知道怎么画。我应该使用 css3 3d 转换
它基本上是一个 flex 的 div: 那么可以只使用 CSS 而不使用图像吗? 最佳答案 嗯...我是这个形状最大的怀疑者,但它似乎是可能的 O_o Demo HTML CSS .shape
我希望在 Java 中创建一个星号梯形,就像下面使用嵌套 for 循环的模式一样。 ** **** ******** 我知道如何打印两个、四个然后六个星号,如下面的代码所示。但是,我不知道如何创建两个
关于 Python 中实时数据的数值积分(梯形)的问题- 背景:实时测量一个平均速度为 100 米/分钟的移动物体,我每 100 毫秒采样一次,持续 60 秒 - 因此在一分钟结束时,我将获得 600
我很难解决这个问题: 我想用 css 做这个: 如图:两个圆 Angular 的飞人(重要!),一个带文字的飞人,一个带图片,或者图标的飞人,有图标的飞人尺寸可以细一些,但是两个飞人必须是大小相同。
我想创建一个响应式梯形形状,它可以是 CSS、SVG 或 Canvas。 我已经能够创建三 Angular 形,但不能创建响应式的梯形。 div { width: 0; height: 0;
这个问题在这里已经有了答案: css skew element and get inner rounded border top (1 个回答) 关闭 4 年前。 我想用 CSS 和 HTML 自定
这是 css 在 id 上的代码工作正常: border-bottom: 100px solid #0000ff80; border-right: 50px solid transparent; he
我在使用 CSS 时遇到了一个小问题。我需要一个梯形 div,它的左上角( Angular 大于 90 度的那个)是圆 Angular 的。我已经知道了: HTML: CSS: .tr
我在使用 CSS 时遇到了一个小问题。我需要一个梯形 div,它的左上角( Angular 大于 90 度的那个)是圆 Angular 的。我已经知道了: HTML: CSS: .tr
我有这个带有伪元素的形状: https://jsfiddle.net/6gf1m3j5/ body { margin: 0; background:#ccc; } #octagon-l
我在使用 CSS 时遇到了一个小问题。我需要一个梯形 div,它的左上角( Angular 大于 90 度的那个)是圆 Angular 的。我已经知道了: HTML: CSS: .tr
我怎样才能像这里的 Tidal 一样制作一个旋转的横幅 我试过制作梯形并根据 http://browniefed.com/blog/the-shapes-of-react-native/ 将其旋转 4
我正在使用 three.js 制作一个小动画,其中有一些基本的 3D 模型,其中一个我正在努力处理的是“梯形 ”。 到目前为止,我只能在 THREE.CylinderGeometry 的帮助下创建截顶
我正在使用 three.js 制作一个小动画,其中有一些基本的 3D 模型,其中一个我正在努力处理的是“梯形 ”。 到目前为止,我只能在 THREE.CylinderGeometry 的帮助下创建截顶
我是一名优秀的程序员,十分优秀!