Question
c++ help Need to output a matrix but it only outputs A single column that isn't correct (I am running this on a Linux server).
c++ help
Need to output a matrix but it only outputs A single column that isn't correct (I am running this on a Linux server). User should be able to enter contents of matrix manually or from a WAM file by >./progname < WAM which is what I used. User doesn't specify array size but was told that it wouldn't be any more than 10 and it is a square matrix.
My code:
#include
for (int c = 1; c < i; c++) { cin.getline(x, MAX, ' '); stringstream ssin(x); j = 0; while (ssin.good() && j < M) { ssin >> matrix[c][j]; ++j; } }
cout << "The WAM entered is: " << endl; for (int c = 0; c < i; c++) { for (int d = 0; d < j; d++) { cout << matrix[c][d] << " "; } cout << endl; } return 0; }
WAM file content
0 0 355 0 695 0 0 0
0 0 74 0 0 348 0 0
355 74 0 262 0 269 0 0
0 0 262 0 0 242 0 0
695 0 0 0 0 151 0 0
0 348 269 242 151 0 83 306
0 0 0 0 0 83 0 230
0 0 0 0 0 306 230 0
Step 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