Home c++ How to display the entered C++ matrix

How to display the entered C++ matrix

Author

Date

Category

I had a problem, how to withdraw all entered Elerts array, and not just the last string of the matrix.

# include & lt; iostream & gt;
/ * RUN THIS PROGRAM USING THE CONSOLE PAUSER OR ADD Your Own Getch, System ("Pause") OR INPUT LOOP * /
Using Namespace STD;
Int Main (int argc, char ** argv)
{
int n, m;
INT ARR [N] [M] = {};
COUT & LT; & LT; "Vved Kilkist Ryadkiv";
CIN & GT; & gt; n;
COUT & LT; & LT; "Vved Kilkist Stovpziv";
CIN & GT; & GT; m;
COUT & LT; & LT; "Matrizia";
for (int i = 0; i & lt; n; i ++)
{
 for (int j = 0; j & lt; m; j ++)
 {
  COUT & LT; & lt; "Arr [" & lt; & lt; i & lt; & lt; "] [" & lt; & lt; j & lt; & lt; "] =";
  CIN & GT; & GT; Arr [i] [j];
 }
}
for (int i = 0; i & lt; n; i ++)
{
 for (int j = 0; j & lt; m; j ++)
 {
  cout & lt; & lt; arr [i] [j] & lt; & lt; "";
 }
 COUT & LT; & lt; Endl;
}
  SYSTEM ("PAUSE");
  Return 0;
}

Answer 1

If you rearrange the array definition after entering N and M, then the matrix is ‚Äč‚Äčentered / is displayed without any problems.

int n, m;
COUT & LT; & LT; "VVED Kilkist Ryadkiv";
CIN & GT; & GT; N;
COUT & LT; & LT; "Vved kilkist stovpziv";
CIN & GT; & GT; M;
COUT & LT; & LT; "Matrizia";
INT ARR [N] [M] = {0};

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions