কম্পিউটার টিউটোরিয়াল

C++-এ transform_inclusive_scan() ফাংশন


এই টিউটোরিয়ালে, আমরা C++-এ `transform_inclusive_scan()` ফাংশন সম্পর্কে একটি প্রোগ্রাম আলোচনা করব।

উদাহরণ

#include <iostream> #include <vector> using namespace std; namespace point_input_iterator {    template <class InputItrator, class OutputItrator, class BinaryOperation, class UnaryOperation>    OutputItrator transform_inclusive_scan(InputItrator first,       InputItrator last,       OutputItrator d_first,       BinaryOperation binary_op,       UnaryOperation unary_op){             *d_first = unary_op(*first);       first++;       d_first++;       for (auto it = first; it != last; it++) {          //calculating the prefix sum          *d_first = binary_op(unary_op(*it), *(d_first - 1));          d_first++;       }       return d_first;    } } int main(){    //inputting elements using vector    vector<int> InputVector{ 11, 22, 33, 44, 55, 66, 77, 88 };    vector<int> OutputVector(8);    point_input_iterator::transform_inclusive_scan(InputVector.begin(), InputVector.end(), OutputVector.begin(), [](auto xx, auto yy) {       return xx + yy;    },    [](auto xx) {       return xx * xx;    });    for (auto item : OutputVector) {       //printing the output item       cout << item << " ";    }    cout << std::endl;    return 0; }

আউটপুট

121 605 1694 3630 6655 11011 16940 24684

  1. C++-এ strtol() ফাংশন

  2. সি++ STL-এ transform() ফাংশন

  3. C++-এ log() ফাংশন

  4. C++-এ swap() ফাংশন