- #1
Joon
- 85
- 2
- Homework Statement
- I want to read two different text files containing two different matrices in the same program then output the multiplication of the two. To read two different text files, do I need to close the first file then open the second file in the code? But then would the code that comes after (the multiplication code) work?
- Relevant Equations
- I'm trying to write a code that reads any square matrix from 1x1 to 10x10 using the format below.
My matrix text files can vary from 1x1 to 10x10 (Another file will be given when the code gets tested but it's all square matrices)
I'm stuck here.
I'm stuck here.
C:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
const int MAXI = 10;
int x, y, z, xcoordinates[MAXI], ycoordinates[MAXI], zcoordinates[MAXI], row1, column1, row2, column2, i, j, k;
int A[3][3], B[3][1], C[3][1], i, count;
ifstream inFile("matrix(1).txt");
i = 0;
count = 0;
while (inFile >> x >> y >> z) {
xcoordinates[count] = x;
ycoordinates[count] = y;
zcoordinates[count] = z;
count = count + 1;
}
}