# I need very fast help, like within the hour, please!

Show 50 post(s) from this thread on one page
Page 4 of 5 First 12345 Last
• January 16th, 2013, 02:41 PM
GCDEF
Re: I need very fast help, like within the hour, please!
That makes it a little more complicated. You'll want an array for your total counters then too. I'd suggest you read the chapters in your book covering arrays and for loops until they make sense. Keep in mind in your examples, index i accesses the row and index j access the columns. j should only loop over the columns you're interested in. Therefore it won't start at 0.
• January 16th, 2013, 02:46 PM
Re: I need very fast help, like within the hour, please!
lol my book..... i wish i had one, we never had a book for this. Everything we learned is from class and examples given, never seen a book or heard one mentioned.

if i had a book I woulnt have to ask someone how to do it or try to search the internet for random places in english that i bearly can read cuz i dont understand half the c++ lanugae words used.
• January 16th, 2013, 02:47 PM
Alterah
Re: I need very fast help, like within the hour, please!
If you were going to print out the numbers in the array, column by column, how would you do that?
• January 16th, 2013, 02:49 PM
Re: I need very fast help, like within the hour, please!
this is how i get the numbers printed out column by column?

Code:

```printf("========================================\n"); printf("Kolmandast tulbast paremale jäävad tulbad\n"); for(i=0; i<RIDU; i++) { for(j=0; j<VEERGE; j++) {    if (j>2)  printf("%4d", maatriks[i][j]); } printf("\n"); } printf("========================================\n"); for(i=0; i<RIDU; i++) {     nTotal += maatriks[i][2]; } printf("neljas tulp ja selle arvude summad\n"); for(i=0; i<RIDU; i++) { for(j=0; j<VEERGE; j++) {                  if (j<1)  printf("%4d", maatriks[i][3]); } printf("\n"); } printf("----------------------------------------\n"); printf("viies tulp ja selle arvude summad\n"); for(i=0; i<RIDU; i++) { for(j=0; j<VEERGE; j++) {  if (j<1)  printf("%4d", maatriks[i][4]); } printf("\n"); } printf("----------------------------------------\n"); printf("kuues tulp ja selle arvude summad\n"); for(i=0; i<RIDU; i++) { for(j=0; j<VEERGE; j++) {  if (j<1)  printf("%4d", maatriks[i][5]); } printf("\n"); } printf("----------------------------------------\n"); printf("seitsmes tulp ja selle arvude summad\n"); for(i=0; i<RIDU; i++) { for(j=0; j<VEERGE; j++) {          if (j<1)  printf("%4d", maatriks[i][6]); } printf("\n"); } printf("----------------------------------------\n");```
• January 16th, 2013, 02:51 PM
Alterah
Re: I need very fast help, like within the hour, please!
That is way too much code to do that. You should only need 2 for loops. One to iterate through a column, and then the other to move you to the next column.
• January 16th, 2013, 02:53 PM
Re: I need very fast help, like within the hour, please!
i'd be happy with any lenght as long as i could have feagured out how to sum them up
• January 16th, 2013, 02:57 PM
GCDEF
Re: I need very fast help, like within the hour, please!
I'm repeating myself over and over here.
Code:

```for(j=0; j<VEERGE; j++) {  if (j<1)  printf("%4d", maatriks[i][5]); }```
This makes no sense. You're not using j in the loop other than to test if it's less than 1, which is pointless. The range for j needs to be the columns you want to sum. You really need to understand what arrays are, how you access them and how loops work. You can't leave it till the last minute then guess.
• January 16th, 2013, 03:01 PM
Alterah
Re: I need very fast help, like within the hour, please!
That's not a good way to look at the problem. Because of all the extra code, you have too much to look at. On top of that your indention is off, making it even harder.

Here's the basic setup, probably more than I should give, but hopefully it makes things clearer:

Code:

```#define ROW    4 #define COLUMN  7 int Matrix[ROW][COLUMN] = { {1, 2, 3, 4, 5, 6, 7},                             {5, 6, 7, 8, 9, 1, 4},                             {4, 9, 7, 4, 1, 3, 2},                             {3, 2, 5, 5, 5, 9, 1} }; int main() {     int i;     int j;     for( i = 0; i < ???; i++ )     {         for( j = 0; j < ??? j++ )         {             /* do stuff */         }     } }```
That is much easier to read with proper indenting.
• January 16th, 2013, 03:07 PM
Re: I need very fast help, like within the hour, please!
the numbers have to be random generated
• January 16th, 2013, 03:10 PM
Alterah
Re: I need very fast help, like within the hour, please!
That's not your problem right now.
• January 16th, 2013, 03:12 PM
GCDEF
Re: I need very fast help, like within the hour, please!
Quote:

Originally Posted by SwiftXShadow
the numbers have to be random generated

As I said, go read the book about arrays and for loops. Don't write any more code or post here again until you have a pretty good understanding of what they are and how they work.
• January 16th, 2013, 03:55 PM
Re: I need very fast help, like within the hour, please!
still dont have a book, or even know the name of 1 that about the stuff i need to know for my classes.
• January 16th, 2013, 04:27 PM
Alterah
Re: I need very fast help, like within the hour, please!
You can use Google for a resource. I know if you search C++ Arrays the first link is a good source: http://www.cplusplus.com/doc/tutorial/arrays/

In addition, that site is a good resource for anything C++ related.
• January 16th, 2013, 04:30 PM