Question
Need help with a c++ problem. #include //cin,cout #include //vectors #include //Format setw(),right using namespace std; //User Libraries Here //Global Constants Only, No Global Variables
Need help with a c++ problem.
#include //cin,cout #include //vectors #include //Format setw(),right using namespace std;
//User Libraries Here
//Global Constants Only, No Global Variables //Allowed like PI, e, Gravity, conversions, array dimensions necessary const int COLMAX=2;//Only 2 columns needed, even and odd
//Function Prototypes Here void read(vector &, vector &); void copy(vector, vector,int [][COLMAX]); void prntVec(vector, vector,int);//int n is the format setw(n) void prntAry(const int [][COLMAX],int,int,int);
//Program Execution Begins Here int main(int argc, char** argv) { //Declare all Variables Here const int ROW=80; //No more than 80 rows int array[ROW][COLMAX]; //Really, just an 80x2 array, even vs. odd vector even(0),odd(0); //Declare even,odd vectors //Input data and place even in one vector odd in the other read(even,odd); //Now output the content of the vectors // setw(10) prntVec(even,odd,10);//Input even, odd vectors with setw(10); //Copy the vectors into the 2 dimensional array copy(even,odd,array); //Now output the content of the array // setw(10) prntAry(array,even.size(),odd.size(),10);//Same format as even/odd vectors //Exit return 0; }
Purpose: Input numbers and segregate them by placing their values into even or odd vectors based upon their value being even or odd. Thenl a 2-D array with the tirst column containing the contents ot the even vector and the second column containing the odd vector. Output the result and display the contents of the vectors and array. See the sample case for the format of the output. YOURStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started