when I divide a valarray by it's first element, only the first element becomes 1 and others keep their origin value.
#include <iostream>
#include <valarray>
using namespace std;
int main() {
valarray<double> arr({5,10,15,20,25});
arr=arr/arr[0]; // or arr/=arr[0];
for(int value:arr)cout << value << ' ';
return 0;
}
output is
1 10 15 20 25
why the output is not
1 2 3 4 5
I use g++(4.8.1) with -std=c++11
Aucun commentaire:
Enregistrer un commentaire