我有以下代码
#include <iostream>
using namespace std;
int main()
{
double v[3];
double M[3][3];
int i,j;
cout << "Enter in the components of vector v:\n";
for(i=0; i<3; i++)
{
cout << "Component " << i+1 << ": ";
cin >> v[i];
}
cout << "Enter in the elements of matrix M:\n";
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
cin >> M[i][j];
}
}
double Mv[3];
Mv[0] = (M[0][0] * v[0]) + (M[0][1] * v[1]) + (M[0][2] * v[2]);
Mv[1] = (M[1][0] * v[0]) + (M[1][1] * v[1]) + (M[1][2] * v[2]);
Mv[2] = (M[2][0] * v[0]) + (M[2][1] * v[1]) + (M[2][2] * v[2]);
cout << "The product of Mv is: " << Mv[3] << endl;
return 0;
}
当用户输入矩阵的元素时,它只是转到下一行等...
如何使用当用户输入代码时,它显示实际的矩阵,而不仅仅是9个元素的列表。