C++ 每次使用数组和矩阵c++;

C++ 每次使用数组和矩阵c++;,c++,arrays,C++,Arrays,我正在为矩阵编写一个程序,我得到了错误: 错误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

我正在为矩阵编写一个程序,我得到了错误:

错误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;
}
错误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;
}
#包括
使用名称空间std;
int main()
{
char str[3][3]={};
cout-str[0][1]>>str[0][2];
cout-str[1][1]>>str[1][2];
cout-str[2][1]>>str[2][2];

您使用的是非法索引。您使用的数组是str[3][0]超出了范围。最大数组长度总是比指定的长度少一个。您可以使用str[2][0]。

请指定行号。这里的这些行有问题: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 0][2]*str 1][1]);您想在这里做什么?数组是一个同构的数据结构。您不需要在这里强制转换。请解释。您正在数组末尾建立索引。
str 3][0]
不存在。
char str[3][3]
有从
[0][0]
[2][2]
的合法索引……也就是说,“3”是数组大小,但索引是0、1和2。另外,穆罕默德有一个固定点……你到底想做什么?这些表达式最终的形式是
(字符值)[(字符值)]
,这是非法的。首先,如果你使用括号来分组操作,你应该只使用括号。不要使用你在数学课上学到的
{[()]}
模式。其次,你必须明确乘法。你不能说
(-1)(str[1][0])
。你必须做
(-1)*(str 1][0])
.1.不能忽略乘法*2。数组超出了范围