std::transform(first, first + 5, second, results, std::minus<int>()); // Printing the result array for (int i = 0; i < 5; i++) std::cout << results[i] << " "; return 0; } 输出: 90 180 270 360 450 注:本文由VeryToolz翻译自 std::minus in C++ ,非经特殊声明,文中代...
#include <iostream> #include <functional> int main() { auto minus2 = std::bind(std::minus<int>(), std::placeholders::_2, std::placeholders::_1); std::cout << "10 - 20 = " << minus2(10, 20) << std::endl; return 0; } ...
// C++ program to illustrate std::minus// by subtracting the respective elements of 2 arrays#include<iostream> // std::cout#include<functional> // std::plus#include<algorithm> // std::transformintmain(){// First arrayintfirst[] = {100,200,300,400,500};// Second arrayintsecond[] = ...
#include <complex> #include <functional> #include <iostream> int main() { auto complex_minus = std::minus<void>{}; // “void” can be omitted constexpr std::complex<int> z(4, 2); std::cout << complex_minus(z, 1) << '\n'; std::cout << (z - 1) << '\n'; } Output...
不确定你真正想要的是什么,但这可能是有用的: