#include 
#include 

void show(int number)
{
	std::cout << number << std::endl;
}

int main()
{
	std::vector my_integers;
	int index;
	std::vector::iterator it;

	for(index = 0;index < 100;++index)
	{
		my_integers.push_back(index);
	}

	std::cout << "Output from Arrays \n";
	std::cout << "------------------ \n";
	for(index = 0;index < 100; ++index)
	{
		std::cout << my_integers[index] << std::endl;
	}
	
	
	std::cout << "Output from vectors iteratour output \n";
	std::cout << "------------------- \n";
	for(it = my_integers.begin() ; it < my_integers.end() ; it++)
	{
		std::cout << *(it) << std::endl ;
	}
    	std::cout << "\n\n";


	std::cout << "Output from vectors for_each output \n";
	std::cout << "------------------- \n";
	std::for_each (my_integers.begin(),my_integers.end(),show);
	std::cout << "\n\n";


	std::cout << "Search in vectors   \n";
	std::cout << "------------------- \n";
	std::vector::iterator found;
	found = std::find (my_integers.begin(),my_integers.end(),6);
	if(found == my_integers.end())
	{
		std::cout << "Not found   \n\n";
	}
	else
	{
		std::cout << "Look what I found ': " << *found << std::endl << "\n\n";
	}


	std::vector another_copy(20);
	std::copy (my_integers.begin(),my_integers.begin() + 20,another_copy.begin());
	std::cout << "Output from copy vector \n";
	std::cout << "----------------------- \n\n";
	std::for_each (another_copy.begin(),another_copy.end(),show);


	std::vector another_vector;
	std::copy (my_integers.begin(), 
		       std::find (my_integers.begin(), my_integers.end(), 42),
			   std::back_inserter (another_vector));
	std::for_each (another_vector.begin(),another_vector.end(),show);


	
	return 0;

}




Hosted by www.Geocities.ws

1