#include<iostream> // when use function cin, cout
#include<fstream> // when use file stream function fstream or ofstream
#include <cmath> // when used function such as sin, cos, tan, power bagai kne pkai library ni.
#include <iomanip> // when use function such as setprecision, fixed etc
#include <string>
using namespace std;
int main() {
ifstream fp1;
ofstream fp2;
char inputFile[50], outputFile[50], ans, Hx[10], Hy[10], Hz[10], HDiff[20], HDist[20], name1[10], name2[10], name3[10], name4[10], name5[10];
char name6[10], name7[10],name8[10],name9[10],name10[10],name11[10], name[10], Obs, From, To, Date[20], Rl[20], RlB[10], RlC[10], x[10],y[10],z[10];
char v1,v2,v3,h1,h2,h3,A,B,C;
char dF,dx,dG,dH;
double Diff[10], Dist[10],X[20];
int i,j,n,k,c[10][10],d[10][10],e[10][10],f[10][10],transpose[10][10],r1=3,c1=2,r2=3,c2=3,r3=2,c3=1;
int a[3][2] = { {1, 0} , {0, 1}, {-1, 1} };
int W[3][3] = { {10, 0, 0} ,{0, 10, 0}, {0, 0, 10} };
double L[3][1] = { {99.25}, {105.46} , {3.73} };
again:
cout << "Please Enter Input Filename: ";
cin >> inputFile;
fp1.open(inputFile);
if(!fp1)
{
cout << "Input File " << inputFile << " Opss sorry cannot be opened.";
cout << "\nDo You Like to Try Again? (Y/N)";
cin >> ans;
if(ans == 'y' || 'Y') goto again;
return 0;
}
cout << "\nInput File " << inputFile << " readed successfully.";
fp1 >> Date; fp1 >> name >> name1 >> RlB >> name2 >> RlC;
fp1 >> name3 >> name4 >> name5 >> Rl;
fp1 >> name6 >> name7;
fp1 >> name8 >> name9 >> name10 >> name11;
fp1 >> Hx >> Hy >> Hz >> HDiff >> HDist;
for(i=1; i<=3; i++)
{
fp1 >> x[i] >> y[i] >> z[i] >> Diff[i] >> Dist[i]; }
cout << endl ;
cout << "\n" << Date;
cout << "\n" << name << "\n" << "\n" << name1 << "\t" << RlB <<"\t" << name2 << "\t" << RlC;
cout << "\n" << name3 << "\t" << name4 << "\t" << name5 << "\t" << Rl << "\t" << name6;
cout << "\n" << "\n" << name7 << "\t" << name8 << "\t" << name9;
cout << "\t" << name10 << "\t" << name11;
cout << "\n" << Hx << "\t" << Hy << "\t" << Hz << "\t" << HDiff << "\t" << "\t" << HDist;
for (i =1; i<3; i++)
{
cout << "\n" << x[i] << "\t" << y[i] << "\t" << z[i] << "\t" << Diff[i] << "\t" << "\t" << Dist[i];
}
v1=B-A-h1;
v2=C-A-h2;
v3=C-B-h3;
cout << "\n" << "\n" << "v1=B-A-h1" << "\t" << "v1 = B - 100.25 - (-1.00)" << "\t" << "v1=B-99.25" <<endl;
cout << "\n" << "v2=C-A-h2" << "\t" << "v2 = C - 100.25 - 5.21" << "\t\t" << "v2=C-105.46"<<endl;
cout << "\n" << "v3=C-B-h3" << "\t" << "v3 = C - B - 3.73" << "\t\t" << "v1=C-B-3.73"<<endl;
cout << "\nmatrix X";
string m_X[2] = {"\nX =\tB","\tC"};
for (i = 0; i<2; i++) {
cout << m_X[i] << endl;
}
cout<<"\nmatrix A:"<<endl;
for(i=0; i<r1; i++) {
for(j=0; j<c1; j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
cout<<endl;
for(i=0; i<r1; i++)
for(j=0; j<c1; j++) {
transpose[j][i] = a[i][j];
}
cout<<"\nTranspose A:"<<endl;
for(i=0; i<c1; i++) {
for(j=0; j<r1; j++)
cout<<transpose[i][j]<<" ";
cout<<endl;
}
L[i][j] = 0.0;
cout << "\n\nmatrix L: "<<endl;
for (i=0; i<r1; i++) {
for (j=0; j<c3; j++) {
cout << L[i][j]<<" ";
cout<<endl;
}
}
cout << "\n\nmatrix W: "<<endl;
for(i=0; i<r2; i++) {
for(j=0; j<c2; j++)
cout<< W[i][j]<<" ";
cout<<endl;
}
cout<<endl;
for(i=0; i<r1; i++)
for(j=0; j<c1; j++) {
c[i][j] = 0;
}
for(i=0; i<r1; i++)
for(j=0; j<c1; j++)
for(k=0; k<c2; k++) {
c[i][j]+=W[i][k]*a[k][j];
}
cout<<"RLB AND RLC:"<<endl;
cout<<"(A^tWA):"<<endl;
for(i=0; i<r1; i++) {
for(j=0; j<c1; j++)
cout<<c[i][j]<<" ";
cout<<endl;
}
What I have tried:
i try to multiple the matrix 3x3 with 3x2 but the asnwer is wrong please help me