//Code
/* Project Even Odd
by Jacob Wright 2-20-13 */
#include <iostream.h>
#include <lvp\vector.h>
#include <lvp\random.h>
//___________________________________
void sort(vector<int>&sortnum); //Sorts numbers into odd or even
//___________________________________
void even(vector<int>&evennum, vector<int>&oddsnum); //Organizes even numbers
//___________________________________
void odd(vector<int>&oddnum); //Takes odds and organizes them
//____________________________________
int main()
{
randomize();
vector<int>randnum(25);
for (int C=0; C<=24; C++)
randnum[C]=random(100)+1;
cout << "\n\n\n\n\n";
cout << "Randomly Selected Numbers: ";
for (int d=0; d<=23; d++)
cout << randnum[d] << ", ";
cout << randnum[24];
sort(randnum);
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
return(0);
}
//___________________________________
void sort(vector<int>&sortnum)
{
vector<int>evnum;
vector<int>odnum;
int cont=1, conte=1, lengths=sortnum.length();
for (int x=0; x<=lengths-1; x++)
{
if (sortnum[x]%2==0)
{
evnum.resize(cont);
evnum[cont]=sortnum[x];
cont++;
}
else
{
odnum.resize(conte);
odnum[conte]=sortnum[x];
conte++;
}
}
even(evnum, odnum);
}
//____________________________________
void even(vector<int>&evennum, vector<int>&oddsnum)
{
int length=evennum.length();
cout << "\n\n\n";
cout << "Even Numbers: ";
for (int a=0; a<=(length-2); a++)
cout << evennum[a] << ", ";
cout << evennum[length-1];
odd(oddsnum);
}
//____________________________________
void odd(vector<int>&oddnum)
{
int lengths=oddnum.length();
cout << "\n\n\n";
cout << "Odd Numbers: ";
for (int q=0; q<=(lengths-2); q++)
cout << oddnum[q] << ", ";
cout << oddnum[lengths-1];
}
//Output:
http://i.imgur.com/Pq1ENCW.png