cpp14.cpp

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

CPP
33
字号

// Coded by plusir -- Jan.12.2003.
// Standard C++ Bible -- (P670-23-14)

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

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

	for ( int i = 0; i < 5; i++ ) {
		v1.push_back( i ) ;
		v2.push_back( i + 2 ) ;
	}

	ostream_iterator<int> output( cout, " " ) ;
	cout << "The vector one: " ;
	copy( v1.begin(), v1.end(), output ) ;
	cout << endl << "The vector two: " ;
	copy( v2.begin(), v2.end(), output ) ;
	cout << endl ;

	int result = inner_product( v1.begin(), v1.end(), v2.begin(), 0 ) ;

	cout << "Result = " << result << endl ;

	return 0 ;
}

⌨️ 快捷键说明

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