This is the wrong forum for this kind of question and we dont give readymade answers in this forum. Post your effort in correct forum and then maybe you can get the answer to your question.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
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.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
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:
+table 1+ +table 2+
-------- ---------
john rachel
-------- --------
amy sarah
-------- --------
Suzy Megan
Then just shuffle all the ones in table one, using random_shuffle from , 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.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
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.
This?
#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();
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
This?
#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();
}
Hmm i thought he wanted to access the database using the C++ program, pull the data in and then shuffle them. This is the normal shuffling. Anyways you did a great job understanding the guys requirement, which were pretty er... vague.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733