Question: CODE: #include #include #include #include using namespace std; int main() { ifstream in(matrixes.txt); if (in.fail()) { cout < < File did not open please check
CODE:
#include
using namespace std;
int main() { ifstream in("matrixes.txt"); if (in.fail()) { cout << "File did not open please check it "; exit(0); } int rows, cols, i, j, k, t; while (in >> rows) { in >> cols;
float arr[rows][cols]; float sum[cols]; for (i = 0; i < rows; i++) for (j = 0; j < cols; j++) in >> arr[i][j]; for (i = 0; i < cols; i++) { sum[i] = 0; for (j = 0; j < rows; j++) sum[i] += arr[j][i]; } cout << endl << "Input :" << endl; cout << fixed << setprecision(5); for (i = 0; i < rows; i++) { cout << endl; for (j = 0; j < cols; j++) cout << setw(20) << arr[i][j]; } cout << endl << endl << "Sums :" << endl; for (i = 0; i < cols; i++) cout << setw(20) << sum[i]; bool flag = true; for (i = 0, j = cols - 1; i < j; i++, j--) if (sum[i] != sum[j]) { flag = false; break; } cout << endl << endl << "Vartical additive symmetry : " << endl; if (flag) cout << "Yes" << endl; else cout << "No" << endl; for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { for (k = j + 1; k < cols; k++) if (arr[i][j] > arr[i][k]) { t = arr[i][j]; arr[i][j] = arr[i][k]; arr[i][k] = t; }
} } cout << "Sorted :" << endl; cout << fixed << setprecision(5); for (i = 0; i < rows; i++) { cout << endl; for (j = 0; j < cols; j++) cout << setw(20) << arr[i][j]; } } }
matrixes.txt
2 3 12 25 45 56 98 34.5 3 4 1.4 1.6 7.8 7 4.6 6.65 1.24 -2 1 1 0 2
i need help with trying to make the varibles work so that i can read an input file into the program to get rows and columns
at line 19 and 20 issues arrive.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
