[C++]vector合成&削除メモ
#include <iostream>
#include <vector>
using namespace std;
int main(void){
// Your code here!
vector<double> v(96*8,1);
int s = 0, t = 2;
vector<double>::iterator p = v.begin();
cout << "size:" << v.size() << endl;
//vの要素を表示
for (int i = 0; i < v.size(); i++){
cout << v[i] ;
}
for (int c = 0; c < 5; c++){
/*
変数1:s
変数2:t
変数間の平均をとる
v[96*s+i] = ( v[96*s+1] + v[96*t+i] ) / 2;
平均をとった変数を1つ削除する(変数2を削除)
p = v.begin();
p = p + 96*t;
v.erase(p, p+96);
*/
for (int i = 0; i < 96; i++){
v[96*s + i] = (v[96*s + i] + v[96*t + i]);
}
p = v.begin();
p = p + 96*t;
v.erase(p, p+96);
//vのサイズ表示
cout << endl << "size:" << v.size() << endl;
//vの要素を表示
for (int i = 0; i < v.size(); i++){
cout << v[i] ;
}
}
}