将每一行从文件转换为向量后,数字都会更改或破坏! IDK他们为何或如何被摧毁
const
reference = [{ id: 1,value: 10 },{ id: 2,{ id: 3,{ id: 4,value: 5 }],result = reference.map((sum => ({ value },i) => sum += i && value)(0));
console.log(result);
但是如果我删除first_matrix >> temp; 那没关系 顺便说一句,给我第一个[i] [j] -6.27744e + 66 和Yep IK,我可以轻松编写 我的“ first.txt”中有这样的内容
ifstream first_matrix;
first_matrix.open("first.txt");
double temp;
int d;//Dimensions
vector<double> firstv(0);
first_matrix >> d;
//counter should be (d*d) + 1
//cuz we get dimension and here is 2
//and we want get 4 numbers(d*d) and the first line is dimension so (+ 1)
for ( i = 0; i < (d*d) + 1; i++)
{
first_matrix >> temp;
firstv.push_back(temp);
}
double** first = new double* [d];
for (i = 0; i < d; i++)
{
first[i] = new double[d];
for (j = 0; j < d; j++)
{
//as you can see I want to
//put 4numbers of file.txt which is 10,16,102,15
//into first[i][j]
first_matrix >> first[i][j];
std::cout << "Result ["
<< i << "] ["
<< j << "] : "
<< first[i][j];
}
}
所以我有一个2 * 2的矩阵,给我们4个数字。 但是我的问题是从first.txt获取firt [i] [j]。 结果应该是这样
2
10
16
102
15