错误每次我使用数组和矩阵C时间++ [英] Error every time I use arrays and matrices c++

查看:143
本文介绍了错误每次我使用数组和矩阵C时间++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个程序矩阵我得到的错误:

错误C2109:标要求数组或指针类型

错误C2064:术语不计算为服药1参数的函数

错误C2109:标要求数组或指针类型

 的#include<&iostream的GT;使用命名空间std;诠释的main()
{
炭海峡[3] [3] = {};
COUT<<输入第一行塞康排第三行<< ENDL;
霉素>>海峡[0] [0]≥>海峡[0] [1]≥>海峡[0] [2];
COUT<<<< ENDL;
霉素>>海峡[1] [0]≥>海峡[1] [1]≥>海峡[1] [2];
COUT<<<< ENDL;
霉素>>海峡[2] [0]≥>海峡[2] [1]≥>海峡[2] [2];
COUT<<<< ENDL;
STR [3] [0] =(STR [0] [0])[(STR [1] [1] *海峡[2] [2]) - (STR [1] [2] *海峡[2] [ 1])];
STR [3] [1] =( - 1)(STR [1] [0])[(STR [0] [1] *海峡[2] [2]) - (STR [0] [2] *海峡[2] [1])];
STR [3] [2] =(STR [2] [0])[(STR [0] [1] *海峡[1] [2]) - (STR [0] [2] *海峡[1] [ 1])];
STR [3] [3] =(STR [3] [0])+(STR [3] [1])+(STR [3] [2]);
COUT&所述;&下;海峡[3] [3];
的std :: cin.get();
cin.get();
返回0;
}


解决方案

您使用的是非法索引。您正在使用数组str中[3] [0]是出界。最大阵列始终比指定的长度少一个。可以使用STR [2] [0]

I'm writing a program for matrices I get the errors:

error C2109: subscript requires array or pointer type

error C2064: term does not evaluate to a function taking 1 arguments

error C2109: subscript requires array or pointer type

#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;
}

解决方案

You are using Illegal indexes. the array that you are using is str[3][0] is out of bound. the maximum array is always one less than the length specified. you can use str[2][0].

这篇关于错误每次我使用数组和矩阵C时间++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆