c++ - Selecting a string corresponding to the nth number of elements in an array -
There is a very troubling problem here. In this challenge, my goal is to hold the names of 5 most active buyers in quantity To do is to return an array. Stock Symbols are holding those names, while the total purchased has worked successfully and the total is kept in the Bought array. I then tried to do the 5 greatest things at the top and returned my names to the total.
I am a full newbie on C ++, so I know that this method of doing things is wrong. It is also not compiled, to throw away memory errors at all places (if the largest [0] & lt; totalBought [i]) starts on or around the line.
If you Anyone knows better than I would be grateful for your input to successfully make this work, or if you know how to work in this way, it will be very useful.
Many Thank you.
string * analyzer :: topfivebuyyers () {i} // your code string String Styles Balls [] = {"P Bush", "Zero Soros", "Joe Nef", "Hagrevez Lansdown", "Sipple", "Saga", "TotalSold; TotalSold = New String [5]"; "Halifax", "iWeb", "Alliance Trust", "Clubfinance", "Lloyds TSB", "Saxo"}; Intel for total purchase [13]; (Int i = 0; i & lt; nTransactions; i + +) {For (int j = 0; j & lt; 13; j ++) {if (transerer [i] .buyerName == stockscombo [ja]) {totalBought [j] + = transerer [i]. Nmashrars; }}}}} For the largest [] = {-1, -1, -1, -1, -1}; (int i = 0; i
I want you to get a combination map and multi Suggest the map. I took the freedom to change the result of the function to be the vector of strings, which should be sincere to it:
std :: vector & lt; String & gt; Analyzer :: Top Fibers () {Typingfed Map & lt; String, int & gt; Xact_map; Xact_map xacts; For (int i = 0; i & lt; nTransactions; ++ i) extacts [transarer [ii] .burernames] + = transerer [ii] .nom share; // To calculate the map, to eliminate all the elements / is valuable, according to the transaction count instead of the name. // Note This considers one element "less" (and hence the beginning of sequence / //) if the number of shares is * more * Typedef multimap & lt; Int, string, std :: big & lt; Int & gt; & Gt; High_map; Highest_Map highest; (Xact_map :: const_iterator = xacts.begin (); it! = Xacts.end (); ++ this) supreme .interest (supreme_map :: value_type (it-> second, this-> first)); // Now peel the top five elements just by multimap. Of vector & lt; String & gt; result; Int n = 0; For (supreme_map :: const_iterator this = supreme.bugin (); it! = Supreme.and () & amp; amp; amp; amp; 5; ++, ++ n) {results.push_back (it -> second); } Return results; }
Comments
Post a Comment