⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alg18.c

📁 “在遇到无法解决的问题时
💻 C
字号:
#include <numeric>
#include <vector>
#include <iostream.h>
	
int main()
{
	int ia[] =  { 2, 3, 5, 8 };
	int ia2[] = { 1, 2, 3, 4 };

	// multiply the element pair from the two arrays
	// then add to the initial value: 0

	int res = inner_product( &ia[0], &ia[4], &ia2[0], 0); 

	// generates: inner product of arrays: 55
	cout << "inner product of arrays: "
	     << res << endl;
		
	vector<int, allocator> vec(  ia,  ia+4 );
	vector<int, allocator> vec2( ia2, ia2+4 );

	// add the element pair from the two vectors
	// then subtract from the initial value: 0

	res = inner_product( vec.begin(), vec.end(), 
			     vec2.begin(), 0, 
			     minus<int>(), plus<int>() );

	// generates: inner product of vectors: -28
	cout << "inner product of vectors: "
	     << res << endl;
		
	return 0;
}

⌨️ 快捷键说明

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