【发布时间】:2014-04-15 16:35:44
【问题描述】:
对 C++ 完全陌生,我必须使用这种编程语言。而且以前从未做过编程。
基本上我需要从存储的文件中读取一个矩阵,以便在按下调试按钮时可以看到它的输出。
当我尝试做矩阵时
1 3 5
2 4 6
5 7 9
当我阅读它时,它出现了矩阵,但排成一行,所以.... 1 3 5 2 4 6 5 7 9.
如果可能的话,有人知道如何获取它以便将其读取为矩阵吗?
以后我需要找到矩阵等的行列式。并在多个矩阵之间进行其他求和。
这是我目前拥有的:
#include <iostream>
#include <conio.h>
#include <cmath>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
char filename[50];
ifstream matrixA;
cin.getline(filename, 50);
matrixA.open(filename);
if (!matrixA. is_open())
{
exit (EXIT_FAILURE);
}
char word[50];
matrixA >> word;
while (matrixA.good())
{
cout << word << " ";
matrixA >> word;
}
system("pause");
return 0;
}
【问题讨论】:
-
你应该表现出你已经尝试过的一些努力。