Click here to Skip to main content
15,889,335 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: SerialComm Pin
Andy Wieberneit30-Mar-04 23:33
Andy Wieberneit30-Mar-04 23:33 
GeneralRe: SerialComm Pin
okoji6-Apr-04 22:09
sussokoji6-Apr-04 22:09 
GeneralRe: SerialComm Pin
User 91483318-Apr-04 13:12
User 91483318-Apr-04 13:12 
GeneralChange Text (Caption) Color for a MFC Button Pin
HaHa!30-Mar-04 4:54
HaHa!30-Mar-04 4:54 
GeneralRe: Change Text (Caption) Color for a MFC Button Pin
Renjith Ramachandran7-Apr-04 21:14
Renjith Ramachandran7-Apr-04 21:14 
Generalnewbie question Pin
charlener29-Mar-04 7:23
charlener29-Mar-04 7:23 
GeneralRe: newbie question Pin
zena992-Apr-04 8:24
zena992-Apr-04 8:24 
Generalusing iterator to count though vector Pin
wadstar29-Mar-04 6:25
wadstar29-Mar-04 6:25 
ive been working on some simulation code, what i have written basically what it does it creates a Vector and fills it with random DOUBLE numbers from two different sources untill maz_size reached.. what im stuck is i want to go thorugh each element in the vector..prob using an iterator such as input_iterator i think?

so the vector is such..
[number_from_first_source, number_from_secondSource, number from_first source...etc etc]
so every odd element is form source1 and every even element is from source 2..

now i want to go thorugh each element with specific iterator value..example lets say 20ms i.e. 0.002..quite small value. the random numbers are all seeded values. so how owul di go through the vector with this small iterator value.
]#include <iostream><br />
#include <vector><br />
#include <stdlib><br />
#include <time><br />
#include <numeric><br />
#include <algorithm><br />
#include "exponentialgenerator.h"<br />
<br />
using namespace std;<br />
<br />
ExponentialGenerator one = 1.41;<br />
ExponentialGenerator two = 1.71;<br />
<br />
double nextNumber = reinterpret_cast<double>one.generate());<br />
double nextNumber2 = reinterpret_cast<double>two.generate());<br />
int counter = 0;<br />
<br />
void fillVectorToSum(vector<double>& v, double sum)<br />
{<br />
<br />
int total = 0;<br />
do {<br />
if (counter++ % 2){<br />
v.push_back(nextNumber);<br />
total += nextNumber;<br />
nextNumber = one.generate();<br />
}<br />
else {<br />
v.push_back(nextNumber2);<br />
total += nextNumber2;<br />
nextNumber2 = two.generate();<br />
}<br />
<br />
} while(total+nextNumber+nextNumber2 <= sum);<br />
if(total < sum)<br />
v.push_back(sum-total);<br />
}<br />
<br />
int main()<br />
{<br />
<br />
srand((unsigned) time(NULL));<br />
vector<double> v;<br />
fillVectorToSum(v, 30);<br />
<br />
cout << "Number of elements: " << v.size() << "\nTotal: "<br />
<< accumulate(v.begin(), v.end(), 0) << endl;<br />
copy(v.begin(), v.end(), ostream_iterator<double> (cout," "));<br />
<br />
}


the exponentialGenerator.h file i use jus to generate numbers if your wondering....

anyway any input to this problem would be appreciated.
Generalunmanaged class declaring managed member function as friend Pin
godzooky29-Mar-04 4:15
godzooky29-Mar-04 4:15 
GeneralRe: unmanaged class declaring managed member function as friend Pin
Andy Wieberneit30-Mar-04 0:21
Andy Wieberneit30-Mar-04 0:21 
GeneralName Mangling Pin
Member 62566625-Mar-04 5:41
Member 62566625-Mar-04 5:41 
GeneralRe: Name Mangling Pin
Nemanja Trifunovic25-Mar-04 5:49
Nemanja Trifunovic25-Mar-04 5:49 
GeneralRe: Name Mangling Pin
Member 62566625-Mar-04 5:54
Member 62566625-Mar-04 5:54 
GeneralRe: Name Mangling Pin
Rick York25-Mar-04 6:09
mveRick York25-Mar-04 6:09 
GeneralRe: Name Mangling Pin
Member 62566625-Mar-04 7:43
Member 62566625-Mar-04 7:43 
GeneralRe: Name Mangling Pin
Member 62566625-Mar-04 10:20
Member 62566625-Mar-04 10:20 
GeneralRe: Name Mangling Pin
Rahul20067611-Apr-04 4:04
Rahul20067611-Apr-04 4:04 
GeneralProblems with lib file and linking Pin
ravjak24-Mar-04 9:20
ravjak24-Mar-04 9:20 
GeneralRe: Problems with lib file and linking Pin
ian mariano24-Mar-04 17:19
ian mariano24-Mar-04 17:19 
GeneralRe: Problems with lib file and linking Pin
ravjak25-Mar-04 5:17
ravjak25-Mar-04 5:17 
GeneralRe: Problems with lib file and linking Pin
ravjak25-Mar-04 5:22
ravjak25-Mar-04 5:22 
GeneralRe: Problems with lib file and linking Pin
ravjak28-Mar-04 2:42
ravjak28-Mar-04 2:42 
GeneralMixing C++ and C Pin
Member 62566623-Mar-04 8:01
Member 62566623-Mar-04 8:01 
GeneralRe: Mixing C++ and C Pin
ian mariano23-Mar-04 10:17
ian mariano23-Mar-04 10:17 
GeneralRe: Mixing C++ and C Pin
Member 62566623-Mar-04 10:28
Member 62566623-Mar-04 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.