私はプログラミングに慣れていないので、2次元配列(または私の場合は行列)を入力して後で印刷できるコードを書きたいと思います。
#include <iostream>
using namespace std;
void printArray( const int *array, int count )
{
for ( int i = 0; i < count; i++ )
cout << array[ i ] << " ";
cout << endl;
}
int main () {
int n;
cout<<"Please enter the length of your matrix : "<<endl;
cin>>n;
int * y=new int [n];
for (int w = 0; w <= n-1; w++ ) {
y[w] = new int [n];
cout<<"Insert the elements ";
for (int z = 0; z <= n-1; z++)
{
cin >>y [w][z];
}
}
printArray(y, n);
}
ただし、「'int*'から'int'への無効な変換」や「配列の添え字のint[int]型が無効です」などのエラーが発生します。私のコードを確認して、私の欠陥を指摘していただけますか?
ありがとう