用向量除以向量中的所有元素

编程入门 行业动态 更新时间:2024-10-19 16:37:16
本文介绍了用向量除以向量中的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

亲爱的, 我想知道我是否可以将该向量的所有元素除以该向量的最大值 元素。 我检查了STL引用并找到了transform,for_each和最近 BOOST_FOREACH,但是transform和for_each算法不适合 因为我有另一个提供给函数的论据,即 max_element。我想知道这是否可行通过 标准。 BOOST_FOREACH对我来说似乎是最好的选择。但我想知道:) Rgds,

Dear all, I was wondering if I could divide all elements of a vector by the max element of that vector. I checked the STL references and found transform, for_each and lately BOOST_FOREACH, but transform and for_each algorithms are not suited since I have another argument to supply to the functions, namely max_element. I wondered if this is possible or not through the standard. BOOST_FOREACH seemed the best option to me. But I wondered :) Rgds,

推荐答案

utab写道: utab wrote: 亲爱的, 我想知道我是否可以将矢量的所有元素除以最大值 。该向量的元素。 我检查了STL引用并找到了transform,for_each和最近 BOOST_FOREACH,但是transform和for_each算法不适合 因为我有另一个参数供给函数,即 max_element。我想知道这是否可行通过 标准。 BOOST_FOREACH对我来说似乎是最好的选择。但我想知道:) Dear all, I was wondering if I could divide all elements of a vector by the max element of that vector. I checked the STL references and found transform, for_each and lately BOOST_FOREACH, but transform and for_each algorithms are not suited since I have another argument to supply to the functions, namely max_element. I wondered if this is possible or not through the standard. BOOST_FOREACH seemed the best option to me. But I wondered :)

每个人都应该做自己的功课。 V - 请在通过电子邮件回复时删除资金''A' 我没有回复最热门的回复,请不要问

Everybody is supposed to do their own homework. V -- Please remove capital ''A''s when replying by e-mail I do not respond to top-posted replies, please don''t ask

utab写道: utab wrote: 我想知道是否可以将矢量的所有元素除以max 该向量的元素。 I was wondering if I could divide all elements of a vector by the max element of that vector.

写一个简单的for循环真的很难吗?它可能会比STL杂技更容易阅读。 也可能更短。

Is it really that hard to write a simple for-loop? It will probably be easier to read than the STL acrobatics needed to do the same thing. Probably shorter too.

2007年11月15日星期四08:35:52 -0800(太平洋标准时间)在comp.lang.c ++,utab < um ******** @ gmailwrote , On Thu, 15 Nov 2007 08:35:52 -0800 (PST) in comp.lang.c++, utab <um********@gmailwrote, >亲爱的, 我想知道我是否可以通过max 元素划分向量的所有元素那个向量。 我检查了STL引用并找到了transform,for_each和最近的BOOST_FOREACH,但是transform和for_each算法不适合因为我有另一个参数供给函数, >Dear all,I was wondering if I could divide all elements of a vector by the maxelement of that vector.I checked the STL references and found transform, for_each and latelyBOOST_FOREACH, but transform and for_each algorithms are not suitedsince I have another argument to supply to the functions,

你在那里,现在检查绑定家庭,例如 std :: bind2nd或强大的boost :: bind版本。 有些东西(未经检查!) std :: transform(v.begin(),v.end(),v.begin(), std :: bind2nd(std :: divides< double> ;, std :: max_element(v.begin(),v.end()));

You are halfway there, now check the "bind" family, for example std::bind2nd or the powerful boost::bind versions. Something along the lines of (unchecked!) std::transform(v.begin(), v.end(), v.begin(), std::bind2nd(std::divides<double>, std::max_element(v.begin(), v.end()));

更多推荐

用向量除以向量中的所有元素

本文发布于:2023-11-29 17:11:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:向量   元素

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!