26.數值算法
阿新 • • 發佈:2018-03-25
AC urn out enc 實現 iot pos AR spa
- 對容器進行填充
1 void show(int x) 2 { 3 cout << x << endl; 4 }
1 int a[10]; 2 //指定一個數據開始,對a進行填充 3 iota(a, a + 10, 1); 4 5 for_each(a, a + 10, show);
- 容器兩個元素進行計算
1 //數組兩個元素計算 2 cout << accumulate(a, a + 10, -1, [](int x, int y) {return x * y; }) << endl;
- 內積
1
- 乘方
1 cout << pow(2, 10) << endl;
- 求相鄰元素之差與之積
1 int a2[5] = { 1,12,3,14,5 }; 2 int res[5
- 求一個容器的和與積,並把過程保存在一個數組中
1 int a[5] = { 1,23,4,5
26.數值算法