1: //deque_c.cpp 3: #include <iostream> 4: #include <vector> 5: #include <deque> 6: #include <list> 7: using namespace std; 9: int main() 10: { 11: cout << "\nThis program illustrates initialization of a deque " 12: "with components\nfrom non-deque containers. In this case, " 13: "we use a vector and a list."; 14: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 16: int a[] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}; 18: vector<int> intVector(a, a+5); 19: cout << "\nHere are the contents of the vector:\n"; 20: copy(intVector.begin(), intVector.end(), 21: ostream_iterator<int>(cout, " ")); 22: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 24: list<int> intList(a+5, a+10); 25: cout << "\nHere are the contents of the list:\n"; 26: copy(intList.begin(), intList.end(), 27: ostream_iterator<int>(cout, " ")); 28: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 30: deque<int> dFromVector(intVector.begin(), intVector.end()); 31: cout << "\nHere are the contents of the deque " 32: "initialized from the vector:\n"; 33: copy(dFromVector.begin(), dFromVector.end(), 34: ostream_iterator<int>(cout, " ")); 35: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 37: deque<int> dFromList(intList.begin(), intList.end()); 38: cout << "\nHere are the contents of the deque " 39: "initialized from the list:\n"; 40: copy(dFromList.begin(), dFromList.end(), 41: ostream_iterator<int>(cout, " ")); 42: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 43: }