Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(c++) fill even and odd vectors and transfer to a 2D array use following template //System Libraries Here #include //cin,cout #include //vectors #include //Format setw(),right

image text in transcribed(c++) fill even and odd vectors and transfer to a 2D array

use following template

//System Libraries Here #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. Then fill a 2-D array with the first column containing the contents of 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Define and discuss the nature of culture

Answered: 1 week ago

Question

Did the decisions need to be made, or had they already been made?

Answered: 1 week ago

Question

When there was controversy, was it clear who had the final say?

Answered: 1 week ago