60 576
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #20525 in C++ for adrian thomas

Question #20525
Write a C++ function to store the elements of two dimensionl array into one dimensional array row wise
Expert's answer

#include<iostream>
#include<fstream>

using namespace std;

int input(istream& in=cin)
{
int x;
in >> x;
return x;
}

int main()
{
int board[9][9]; //creates a 9*9 matrix or a 2d array.

for(int i=0; i<9; i++) //This loops on the rows.
{
for(int j=0; j<9; j++) //This loops on the columns
{
board[i][j] = input(); //you can also connect to the file
//and place the name of your ifstream in the input after opening the file will
//let you read from the file.
}
}

for(int i=0; i<9; i++) //This loops on the rows.
{
for(int j=0; j<9; j++) //This loops on the columns
{
cout << board[i][j] << " ";
}
cout << endl;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions