每次使用数组和矩阵c++时都会出错
Error every time I use arrays and matrices c++
我正在为矩阵编写一个程序,我得到了错误:
错误C2109:下标需要数组或指针类型
错误C2064:术语的计算结果不是采用1个参数的函数
错误C2109:下标需要数组或指针类型
#include <iostream>
using namespace std;
int main()
{
char str[3][3] = { };
cout <<"Input first row secon row third row"<<endl;
cin >>str[0][0]>>str[0][1]>>str[0][2];
cout <<""<<endl;
cin >>str[1][0]>>str[1][1]>>str[1][2];
cout <<""<<endl;
cin >>str[2][0]>>str[2][1]>>str[2][2];
cout <<""<<endl;
str[3][0]= (str[0][0])[(str[1][1]*str[2][2])-(str[1][2]*str[2][1])];
str[3][1]= (-1)(str[1][0])[(str[0][1]*str[2][2])-(str[0][2]*str[2][1])];
str[3][2]= (str[2][0])[(str[0][1]*str[1][2])-(str[0][2]*str[1][1])];
str[3][3]= (str[3][0])+(str[3][1])+(str[3][2]);
cout <<str[3][3];
std::cin.get();
cin.get();
return 0;
}
您使用的是非法索引。您正在使用的数组是str[3][0]超出了绑定范围。最大数组总是比指定的长度少一个。您可以使用str[2][0]。
相关文章:
- 访问者访问变体并返回不同类型时出错
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 在Google Kick start中提交时出错
- 在c++中访问int到类对象的映射时出错
- 分段错误当我试图运行程序时出错
- 使用dynamic_cast和构造函数时出错
- CHECK(调用)函数在Google Colab中出错
- 用pybind11包装C++抽象类时出错
- 为x86而非x64编译时出错
- 从R调用C++函数并对其进行集成时出错
- 这个函数哪里出错了
- C++ 创建包含链表和字符串的对象的链接列表时出错
- 为重写std::exception的库生成swig接口时出错
- 导入/导出变量时出错
- PrintWindow函数在notepad.exe中出错