我的程序跳过if语句
My program skips the if statement
我正在编写一个程序,它将生成矩阵的幂。正如你所看到的,我试图在for(int n…)循环中询问是否n=0,但当我调试时,我看到程序跳过了条件,甚至没有输入它。我的意思是,如果n=0…,它甚至不会"问"这个问题
问题出在哪里?
void Matrix::pow(int power, Matrix & result)
{
for (int i = 0; i < power-1; i++)
{
for (int j = 0; j < rows; j++)
{
for (int k = 0; k < cols; k++)
{
for (int n = 0; n < cols; n++)
{
if (n==0)
{
(&result)->_array[i][j] == 0; //Reset result's array.
}
(&result)->_array[i][j] += this->_array[i][n] * this->_array[n][j];
}
}
}
}
}
这是一个布尔表达式,而不是赋值。
(&result)->_array[i][j] == 0; //Reset result's array.
相关文章:
- Insert函数不适用于2 if语句C++
- If语句未被求值C++
- C++嵌套if语句,基本货币交换
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- If语句在c++中被忽略
- 比较if语句中的数组值和int值
- 以在Qt中的IF语句中设置时间延迟
- Craps游戏问题,忽略if语句
- c++:定义if语句中的模板
- C++嵌套的 If 语句中,它无法按预期工作
- 如果条件不相关,我应该更喜欢两个 if 语句而不是 if-else 语句吗?
- 需要有关此 if 语句的帮助
- 转换器练习:跳过 if 语句和 if 语句
- 避免在 C++ 中的 if 语句中递增
- 如果仍然不满足要求,如何使 if 语句重复?
- do while 循环中的 if 语句以 yes 或 no 结尾
- 为什么在此C++代码中触发此 if 语句?
- 如何基于平台在制作文件中制作if语句?
- 在 if 语句中使用 GetKeyState 时,它会跳过条件
- C++ If 语句,从其他语句重复