Discrete solution help!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 2
Reputation: burhanms is an unknown quantity at this point 
Solved Threads: 0
burhanms burhanms is offline Offline
Newbie Poster

Discrete solution help!

 
0
  #1
Nov 20th, 2008
Hello,

I work on a problem and I want my solution to be picked from discrete numbers.( I want a value for diameter and I want it to be selected from the available diameter values)

Does anyone know it can be done with C++ and how?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,831
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 297
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Discrete solution help!

 
0
  #2
Nov 20th, 2008
I'm not sure if I understand the question correctly, but if you want a bunch of numbers which you can choose from, you could use vectors.
Example:
  1. vector<int> diameters;
  2. /* load a few bogus values */
  3. diameters.push_back(1);
  4. diameters.push_back(5);
  5. diameters.push_back(7);
  6. /*display available numbers */
  7. cout << "numbers available: ";
  8. for (unsigned int i = 0; i < diameters.size(); i++)
  9. cout << diameters[i] << " ";

output: numbers available: 1 5 7
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 973
Reputation: Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough 
Solved Threads: 107
Alex Edwards's Avatar
Alex Edwards Alex Edwards is offline Offline
Posting Shark

Re: Discrete solution help!

 
0
  #3
Nov 20th, 2008
If you have a finite number of values and they aren't going to change, you can get away with using a standard array instead of a vector.

This is only if you have a static amount of values and performance is an issue. If performance doesn't matter, use a vector as suggested from niek_e since you get the perks of a dynamic array as well as information about its size and the ability to use STL algorithms with it to manipulate, copy or iterate through its contents... etc.

-Alex
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 948
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: Discrete solution help!

 
0
  #4
Nov 20th, 2008
You mean if you have a radius, circumference, etc. then solve it?

http://www.mathopenref.com/diameter.html
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC