1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <valarray>
#include <iostream>
int main()
{
std::valarray<int> a = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120 } ;
std::valarray<int> b = { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } ;
std::valarray<std::size_t> i = { 1, 3, 5, 7, 9 } ;
for( int v : a ) std::cout << v << ' ' ; std::cout << '\n' ;
a[i] = 99 ;
for( int v : a ) std::cout << v << ' ' ; std::cout << '\n' ;
a[i] = b[i] ;
for( int v : a ) std::cout << v << ' ' ; std::cout << '\n' ;
a[i] += b[i] ;
for( int v : a ) std::cout << v << ' ' ; std::cout << '\n' ;
}
|