将矩阵写入txt文件中;每行C 之后
writing a matrix into a txt file with ; after each row C++?
我有一个矩阵" powermatrix",该尺寸为24 * 24,现在我需要知道如何将此矩阵写入带有a的文本文件中;每行之后?我怎样才能做到这一点?到目前为止,我有这个代码,但是我不知道为什么,但是我无法使用A分开;每行之后?
std::ofstream output("Power vector.txt");
for (k=1; k<PowerMatrix.size(); k++)
{
for (l=1; l<PowerMatrix.size(); l++)
{
output << PowerMatrix[i][j] << " "; // behaves like cout - cout is also a stream
}
output << "n";
}
只需在newline之前添加;
:
std::ofstream output("Power vector.txt");
for (k=1; k<PowerMatrix.size(); k++)
{
for (l=1; l<PowerMatrix.size(); l++)
{
output << PowerMatrix[i][j] << " "; // behaves like cout - cout is also a stream
}
output << ";" << endl;
}
相关文章:
- 如何逐行读取文件,每行中的内容都用空格分隔并将其写入新文件中
- C++ 中的二维整数数组,每行中的元素数量不均匀
- 如何在 CSR 矩阵的对角线块中计算每行的非零数
- fftw:为什么我的 2D DFT 输出与每行的 1D DFT 输出不同?
- 如何找到每行的最大值和最小值
- 每像素字节数,每行字节数-如何在tess二的tessbaseapi.cpp中使用函数nativeSetImageByte
- 阅读每行不同栏目的全文
- 在获取从文件到矢量的每一行之后,数字将被更改或销毁
- 如何创建一个具有可变行且每行有 3 列的 2D 数组?
- C++如何通过忽略每行的第一个字符来读取 unicode 文件
- clang 格式:始终断开所有参数,每行一个
- CIN 会丢失每行的前几个字符
- 检查数组行中每行C++是否始终存在相同的值
- 视觉在C 中获取每行代码的执行时间
- 不稳定的C :每行适应性变化多变量初始化
- 如何计算 2D 数组中每行的总和并放置在向量中
- 如何用 c++ 读取 txt 文件,如果我们不知道其中有多少个数据字符串,以及每行有多长?
- 将矩阵写入txt文件中;每行C 之后
- 如何在2D数组中每行之后进入下一行
- 如何在读取文本文件时跳到每行最后一个数字之后的下一行