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

📄 chapter11-31.cpp

📁 C++STL程序员开发指南
💻 CPP
字号:
//文件名:CHAPTER11-31.cpp
#include <iostream>
#include <numeric>
#include <functional>
#include <vector>
#include <iterator>
using namespace std;
typedef vector < int > IntArray;
typedef ostream_iterator < int, char, char_traits<char> > IntOstreamIt;
void main ()
{
    IntOstreamIt itOstream(cout," ");
    IntArray rgI;    // Initialize the array
    for (int i=1; i<=10; i++) rgI.push_back(i);
    cout << "Array: ";    // Print the arrays
    copy(rgI.begin(),rgI.end(),itOstream);
    cout << endl;
    IntArray rgIresult(rgI.size());
    partial_sum(rgI.begin(),rgI.end(),rgIresult.begin());
    cout << "Array of partial sums: ";    // Print the array of partial sums
    copy(rgIresult.begin(),rgIresult.end(),itOstream);
    cout << endl;
    // Compute the partial product of the array
    partial_sum(rgI.begin(),rgI.end(),rgIresult.begin(),multiplies<int>());
    cout << "Array of partial products: ";    // Print the array of partial products
    partial_sum(rgIresult.begin(),rgIresult.end(),itOstream);
    cout << endl;
}

⌨️ 快捷键说明

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