Description of this paper

CSCI 152 Two Dimension Array




Write a complete program to read a data file that contains data for a two dimension array, store the data into a;two dimension array, and searches for all occurrences of a specific value in the array entered from the keyboard;by the user. The file may contain many sets of data. You will create a text file called ?Data2d.txt? and store as;many values as you wish. The first two values for each set of data in the file will be the number of rows and;columns to be used in the two dimension array followed by the actual numbers to be stored in the array.;/* CSCI 152 Fall 2013 Program 7;program will read data for a two dimension array from a file;file may contain multiple data sets to process;program will enter a search value to find in the two dimension array;progran will find the locations (offset) where the search value occurred and store the location;in a single dimension array;user will continue searching for values until they want to quit;*/;#include // header file to read data from a file;#include;#include // header file to use I/O manipulators for display;using namespace std;void read_file(short data[][15], short size, short cols, ifstream &&filein);void display_2darray(short data[][15], short rows, short cols);void find_value(short data[][15], short rows, short cols, short locations[], short &lsize, short search_value);void display_1darray(short data[], short size, short columnSize);int main();short data[15][15];rows;cols;locations[225];lsize;search_value;response;// original data set with 15 rows and 15 columns;// number of rows of data in 2 dimension array;// number of columns of data in 2 dimension array;// array to store the locations of the search value;// number of values stored in locations arrays;// search value entered by user;// input from user to continue inner loop;ifstream filein("data2d.txt"), // input file must be in same folder with exe file;while(filein>>rows>>cols) // read number of rows and columns from file, loop terminates when file empty;read_file(data, rows, cols, filein);cout<<"the array has "<search_value;find_value(data, rows, cols, locations, lsize, search_value);if(lsize);cout<<"the search value was found in "<response;while(response);cout<<"\nprogram done\n;system("pause");CSCI 152;Programming Fundamentals II;Program 7(two dimension array manipulation);Searching a two dimension array;Assignment requirements continued;Fall 2013;11/6/2013;The program must contain functions to perform the following operations.;Write a function, read_file, to store values in a two dimension array obtained from a data file named ?;?Data2d.txt?. The file may contain multiple data sets. The first two values for each data set will be the;number of rows and number of columns of data for the two dimension array followed by the actual;numbers to store in the array. For example, 3, 5 will followed by three lines of data, each line has 5;values. The size of the data set was read in main. Do not input the size in this function. The function;has 4 arguments, the array name, rows, columns, and the file pointer, such as filein (see above).;Write a function, display_2darray, to print the values in the two dimension array so that the numbers are;aligned in columns and each row is printed on a separate line. The function will the use of the setw();function to align the data. One additional header file will be necessary to use the i/o manipulators #include. The function has 3 arguments, array, rows and columns.;for(i=0, i


Paper#70304 | Written in 18-Jul-2015

Price : $22