Assign value to valarray : valarray subscript indexer « valarray « C++ Tutorial






#include <iostream>
#include <valarray>
#include <cmath>
using namespace std;
   
int main()
{
  valarray<int> v(10);
  int i;
   
  for(i=0; i<10; i++) v[i] = i;
   
  cout << "Original contents: ";
  for(i=0; i<10; i++)
    cout << v[i] << " ";
  cout << endl;
   
   
  return 0;
}








20.2.valarray subscript indexer
20.2.1.Assign value to valarray
20.2.2.Use subscript to assign value to valarray
20.2.3.Manipulate the value in a valarray