Insert data into array

I'm really new in c++ and i need a suggestion regarding the topic in the object.
I have two vectors of 248 elements each, vector a and vector b. I calculate the max, min and mean value of those element and than i normalise the vector using the standard formula:
xn_i = (xi-min)/(max-min). My task is to build the new normalize vector and display it.



for (int i = 0; i < l; i++) {
a_norm_mean[i] = (a[i] - min1) / (max1 - min1);
b_norm_mean[i] = (b[i] - min2) / (max2 - min2);
}
in this way i calculate the single element of the new vector. How i can display the whole vector and save the new vector in a file?

double a_norm_mean[248];
double b_norm_mean[248];
double a2[248];

for (int i = 0; i < l; i++) {
a_norm_mean[i] = (a[i] - min1) / (max1 - min1);
b_norm_mean[i] = (b[i] - min2) / (max2 - min2);
a2[i] = a_norm_mean[i];

ofstream writer("a_norm_mean.txt");
if (writer.is_open()) {
writer << a2[i];
}
else
{
cout << "Error" << endl;
}
writer.close();
}
Whit this code i'm able to write the file but i got only one value.


Thank's
Last edited on
Solved
Topic archived. No new replies allowed.