두 가지 질문이 있습니다.벡터를 사용하여 값을 인쇄하는 방법 및 배열 끝에 값을 추가하는 방법은 무엇입니까?
1- 아래 명시된 코드에 대해 어떻게 값을 인쇄 할 수 있습니까 ???
#include <iostream>
#include <list>
using namespace std;
int main()
{
int i;
list<int> a;
for(i; i<5; i++)
{
a.push_back(i);
}
system("pause");
return 0;
}
2 정수 배열에 새 요소를 추가하려면 어떻게합니까?
int *a;
int size = 3
a = new int [size];
a[0]=0;
a[1]=1;
a[2]=2;
//Now, I would like to add a new element to my array by increasing its size by one
size += size; // new size is 4
가 어떻게 새로운 크기로 내 배열을 사용하여 배열의 마지막에 새로운 요소를 추가 할 수 있습니다 : 예를 들어, 내가 배열하도록 있나요?
하지만 memcpy는 [POD types] (http://stackoverflow.com/questions/146452/what-are-pod-types-in-c)에서만 사용할 수 있습니다. –