Patrick B. answered 04/23/20
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <stdlib.h>
void OutputTable( int * evens, int * odds)
{
cout << " index evens odds" << endl;
for (int iLoop=0; iLoop<50; iLoop++)
{
cout << " " << iLoop << " " << evens[iLoop] << " " << odds[iLoop] << endl;
}
}
int Go()
{
int evens[50];
int odds[50];
for (int iLoop=0; iLoop<50; iLoop++)
{
odds[iLoop]=2*iLoop+1;
evens[iLoop] = 2*(iLoop+1);
}
OutputTable(evens,odds);
//shuffles
for (int iLoop=0; iLoop<50; iLoop++)
{
int iRandomIndexEven = rand()%50;
int iRandomIndexOdd = rand()%50;
int iTemp = odds[iLoop];
odds[iLoop] = odds[iRandomIndexOdd];
odds[iRandomIndexOdd] = iTemp;
iTemp = evens[iLoop];
evens[iLoop] = evens[iRandomIndexEven];
evens[iRandomIndexEven] = iTemp;
}
cout << " ************************************************" << endl;
OutputTable(evens,odds);
return 0;
}
int main()
{
return Go();
}