cpp11.cpp

来自「C++参考书」· C++ 代码 · 共 42 行

CPP
42
字号

// Coded by plusir -- Jan.12.2003.
// Standard C++ Bible -- (P663-23-11)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std ;

int main()
{
	vector<string> v1, v2, v3( 10 ) ;

	v1.push_back( "Zebra" ) ;
	v1.push_back( "Deer" ) ;
	v1.push_back( "Fish" ) ;
	v1.push_back( "Snake" ) ;
	v1.push_back( "Bat" ) ;

	v2.push_back( "Cat" ) ;
	v2.push_back( "Bird" ) ;
	v2.push_back( "Turtle" ) ;
	v2.push_back( "House" ) ;
	v2.push_back( "Cow" ) ;

	sort( v1.begin(), v1.end() ) ;
	sort( v2.begin(), v2.end() ) ;

	ostream_iterator<string> output( cout, "\n" ) ;
	copy( v1.begin(), v1.end(), output ) ;
	cout << endl ;
	copy( v2.begin(), v2.end(), output ) ;
	cout << endl ;

	merge( v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin() ) ;
	copy( v3.begin(), v3.end(), output ) ;
	cout << endl ;

	return 0 ;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?