| | |
Help! How to pull numbers from table at random
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Maybe you should start here:
http://www.daniweb.com/techtalkforums/forum16.html
Hope it helped, bye.
http://www.daniweb.com/techtalkforums/forum16.html
Hope it helped, bye.
I don't accept change; I don't deserve to live.
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Sorry, I must not have been clear in my original post. Thanks for clearing that up for me. I posted in the C++ forum because I want a C++ solution, not a T-SQL solution. I am already well versed in T-SQL, have explored it as a solution and found it lacking. I was led to believe that code samples are, in fact, posted on this forum when I saw the this thread:
http://www.daniweb.com/techtalkforums/thread55844.html
It's located in this forum and has code samples galor. Listen, I really do appreciate you helping me to clarify my post, but if you don't have a real solution to my dilemma, in the future just push on to the next and spare me your replies please.
Thanks
http://www.daniweb.com/techtalkforums/thread55844.html
It's located in this forum and has code samples galor. Listen, I really do appreciate you helping me to clarify my post, but if you don't have a real solution to my dilemma, in the future just push on to the next and spare me your replies please.
Thanks
If you have a dilemma post the real question to your dilemma instead of being vague all over. And whats up with this kind of attitude? Maintain it and you would be sure to make a lot many friends here.
And as far as pushing on to the next thing is concerned, this is a public forum where everyone is free to post whatever they like unless the content is filtered by the moderator. So if you dont want to get disturbed with these dilemmas move on to a Pay Site for homework help or learn to live with this.
And as far as pushing on to the next thing is concerned, this is a public forum where everyone is free to post whatever they like unless the content is filtered by the moderator. So if you dont want to get disturbed with these dilemmas move on to a Pay Site for homework help or learn to live with this.
I don't accept change; I don't deserve to live.
What are you having problem with then? Generating random numbers in c++?
I think the following would be the best idea...
Let's say your table looked like this:
Then just shuffle all the ones in table one, using random_shuffle from <algorithm>, and shuffle all the ones in table two using random_shuffle.
Then just print them off side by side. And you have your pairs randomly assigned.
If you want a sample code just ask.
I think the following would be the best idea...
Let's say your table looked like this:
C++ Syntax (Toggle Plain Text)
+table 1+ +table 2+ -------- --------- john rachel -------- -------- amy sarah -------- -------- Suzy Megan
Then just shuffle all the ones in table one, using random_shuffle from <algorithm>, and shuffle all the ones in table two using random_shuffle.
Then just print them off side by side. And you have your pairs randomly assigned.
If you want a sample code just ask.
*Voted best profile in the world*
•
•
•
•
iamthwee,
You are correct. That is basically what I am after. I need a code sample that would shuffle values from a column in one table and pair them at random with values in another table. If you have a code sample I would really appreciate it.
C++ Syntax (Toggle Plain Text)
#include <algorithm> #include <iostream> #include <string> #include <vector> #include <ctime> using namespace std; int main() { srand(time(NULL)); //make it so that everytime you run //the program you get different results vector <string> vc; vc.push_back("susan"); //fill vector vc.push_back("amy"); vc.push_back("heather"); vc.push_back("zoe"); cout << "The original list is:\n"; for ( int i=0; i<vc.size(); i++) { cout << vc[i] <<" "; /*display the original list*/ } random_shuffle(vc.begin(), vc.end()); /* shuffle elements */ cout<<"\n\n\nThe shuffled list is:\n"; for ( int i=0; i<vc.size(); i++) { cout << vc[i] <<" "; } /* display shuffled elements */ cin.get(); }
*Voted best profile in the world*
•
•
•
•
This?
C++ Syntax (Toggle Plain Text)
#include <algorithm> #include <iostream> #include <string> #include <vector> #include <ctime> using namespace std; int main() { srand(time(NULL)); //make it so that everytime you run //the program you get different results vector <string> vc; vc.push_back("susan"); //fill vector vc.push_back("amy"); vc.push_back("heather"); vc.push_back("zoe"); cout << "The original list is:\n"; for ( int i=0; i<vc.size(); i++) { cout << vc[i] <<" "; /*display the original list*/ } random_shuffle(vc.begin(), vc.end()); /* shuffle elements */ cout<<"\n\n\nThe shuffled list is:\n"; for ( int i=0; i<vc.size(); i++) { cout << vc[i] <<" "; } /* display shuffled elements */ cin.get(); }
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- Random Numbers on button (Java)
- C++ Random Numbers (C++)
- Trying to find a better way to generate random numbers in Dev Pascal (Pascal and Delphi)
Other Threads in the C++ Forum
- Previous Thread: static data member help
- Next Thread: The round-robin scheduler
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






