I need help with converting this to c++
Input the n x n matrix A and n element vector b
for k = 1 to n
for i = k + 1 to n
lik aik=akk
for j = k + 1 to n
aij to aij - likakj
end for
end for
end for
I need help with converting this to c++
Input the n x n matrix A and n element vector b
for k = 1 to n
for i = k + 1 to n
lik aik=akk
for j = k + 1 to n
aij to aij - likakj
end for
end for
end for
What exactly is your trouble with it?
And what's l in the psudo code?
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
IDK, the professor for my linear algebra class decided to give us this code to see if we could convert it to c++
this is what I came up with..
Code:#include <iostream> using namespace std; int main() { int i; int m; int n; cout<<"Input Matrix Size: "; cin>>i; cout<<"Input number of rows: "; cin>>m; cout<<"Input number of columns: "; cin>>n; for(m=1; n-1) cout<<b(m)-0 for(n-1; N-1) cout<<a(m,n)=0 end; for(a(m,m+1) cout<<-1 for(a(m,m) cout<<=2 for(a(m+1,) cout<<=-1 end; system("pause"); return 0; }
Using a compiler and a C++ book on hand might help. There are too many errors in that to make it worth the time of anyone here to itemize, particularly since you are liable to make more errors correcting.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
In all fairness the bit prior to the first for loop isn't too bad, but the rest of it may as well be "Mary had a little lamb" as far as a compiler is concerned.
You can't use this forum to get you there, you need another source to learn from first. So many people don't seem to get that there is no shortcut in learning to program. "Do or do not; there is no try".
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"