Вы находитесь на странице: 1из 2

// dynamic_struct.cpp : Defines the entry point for the console application.

//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <list>
using namespace std;
void func(list<int> M)
{
list<int> M1(M.size()); //
list<int> M2(M.size());
list<int>::iterator it;
copy(M.begin(), M.end(), M1.begin()); // 1
it = M1.begin();
cout << "List M1 : " ; // 1
while(it!=M1.end())
{
cout << *it << " ";
it++;
}
cout << endl;
reverse(M.begin(), M.end()); //
copy(M.begin(),M.end(), M2.begin()); // 2
it = M2.begin();
cout << "List M2 : ";
while(it!=M2.end())
{
cout << *it << " ";
it++;
}
}
int main()
{
unsigned int i;
list<int> M; //
list<int>::iterator it;
for ( i = 0; i < 5; i++) //
M.push_back(i * 10);
cout << "List M : " ;
it = M.begin(); //
while(it!=M.end()) //
{
cout << *it << " ";
it++;
}
cout << endl;

func(M); //
_getch();
cout << endl;
}

Вам также может понравиться