#include <iostream>
#include <vector>
#include <algorithm> //fill_n을 쓰기위한 헤더
using namespace std;
int main()
{
int data1[10]{ 0, };
//fill_n은 fill과 같지만, 2번째 인자를 종료위치가 아닌 갯수로 받습니다.
fill_n(data1, 2, 10); //10,10,0,0,0,0,0,0,0,0
fill_n(data1 + 4, 3, 20); //10,10,0,0,20,20,20,0,0,0
cout << "== data1 결과 ==" << endl;
for (int i = 0; i < 10; i++)
cout << data1[i] << ", ";
vector<int>data2({ 0,1,2,3,4,5,6,7 });
fill_n(data2.begin(), data2.size() - 1, 30); // 30,30,30,30,30,30,30,7
fill_n(data2.begin(), 4, 40); //40,40,40,40,30,30,30,7
cout << endl<<endl<< "== data2 결과 ==" << endl;
for (int i = 0; i < 10; i++)
cout << data2.at(i) << ", ";
return 0;
}