cout << "The largest value of the matrix is: " << largest << endl;
cout << "Row coordinate is: " << row << endl;
cout << "Column coordinate is: " << column << endl;
}
void diagonal(apmatrix <int> A, int i, int j)
{
int diag_sum = 0;
for (i; i < A.numrows(); i++)
{
for (j; j < A.numcols(); j++)
{
if (j == i)
diag_sum = diag_sum + A[i][j];
}
}
cout << "Sum of the diagonal values is: " << diag_sum << endl;
}
PaulWendt
April 2nd, 2003, 08:50 PM
First off, use #include <iostream> and not iostream.h. This has
to come up at least 10 times every week.
Secondly, post your code inside of [ c o d e ] and [ / c o d e ]
segments, but without the extra spaces. This comes up often too.
Edit: You have since reformatted your code.
Lastly, we have no idea what you want us to help you with. I
don't feel that I should have to copy all of your code and try to
compile it. You should give a description of whatever problem you
are having and then ask the appropriate question. From what
you posted, I don't have any idea whether you're just getting a
compiler error or a run-time/logic error ... and I'm not about to
compile it to find out.
--Paul
Jigglychu
April 2nd, 2003, 08:52 PM
no, he was just posting it here specifically so that i could help him out :) thats why he didn't specify :)
Nightblade
April 2nd, 2003, 08:53 PM
sorry...just signed up for this forum...im a friend of Jigglychu and we are both in the same class with the terrible santa claus of a teacher... my question is with the last function...the diagonal addition...when i run it, it just gives the first value in the matrix (0,0)...when its supposed to add all the diagonal values of the matrix
cout << "The largest value of the matrix is: " << largest << endl;
cout << "Row coordinate is: " << row << endl;
cout << "Column coordinate is: " << column << endl;
}
void diagonal(apmatrix <int> A)
{
int diag_sum = 0;
for (int i = 0; i < A.numrows(); i++)
{
for (int j = 0; j < A.numcols(); j++)
{
if (j == i)
diag_sum = diag_sum + A[i][j];
}
}
cout << "Sum of the diagonal values is: " << diag_sum << endl;
}
Nightblade
April 2nd, 2003, 09:16 PM
Thanks b!
Paul McKenzie
April 2nd, 2003, 10:47 PM
Originally posted by Nightblade
sorry...just signed up for this forum...im a friend of Jigglychu and we are both in the same class with the terrible santa claus of a teacher... my question is with the last function...the diagonal addition...when i run it, it just gives the first value in the matrix (0,0)...when its supposed to add all the diagonal values of the matrix When you post on a public forum, everyone who is on the forum is entitled to comment. CodeGuru isn't a chat room. Your subject of "matrix" will make participants in CodeGuru believe that the topic concerns using a matrix C++ library, or a problem with using such a library, etc. Instead, they are greeted with a bunch of code with no context.
Why not both of you exchange e-mails if the intent is to send messages back and forth without anyone else participating? Also, shouldn't each of you fix your own work?
Regards,
Paul McKenzie
galathaea
April 2nd, 2003, 11:02 PM
Plus its still wrong... unless they don't really want to learn how to write c++...
Jigglychu
April 3rd, 2003, 05:41 AM
Well, the thing is, he tried to fix his program and it wouldn't work, so as a last resort he asked me to help him, so i did. As to the email, he just wanted to check out this forum b/c our teacher is not very good, and he teaches the program like C. In the future, we will keep it to emails, but please understand that not everyone here is an expert programmer. In our case, we didnt even know what STL was until i posted a thread here.
Even if the program is coded w/ deprecated tags and in noobish ways, it still fulfills its inteded purpose, as verified when i compile it. Please understand, we are only 16, and in an AP computer science course where our teacher isn't very good at all. He teaches coding in non-standard ways, and C++ more like C.
So please, be nice :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.