CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 69
  1. #46
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  2. #47
    Join Date
    Jan 2013
    Posts
    32

    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.

  3. #48
    Join Date
    Aug 2009
    Posts
    440

    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?

  4. #49
    Join Date
    Jan 2013
    Posts
    32

    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");

  5. #50
    Join Date
    Aug 2009
    Posts
    440

    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.

  6. #51
    Join Date
    Jan 2013
    Posts
    32

    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

  7. #52
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  8. #53
    Join Date
    Aug 2009
    Posts
    440

    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.

  9. #54
    Join Date
    Jan 2013
    Posts
    32

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

    the numbers have to be random generated

  10. #55
    Join Date
    Aug 2009
    Posts
    440

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

    That's not your problem right now.

  11. #56
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

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

    Quote Originally Posted by SwiftXShadow View Post
    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.

  12. #57
    Join Date
    Jan 2013
    Posts
    32

    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.

  13. #58
    Join Date
    Aug 2009
    Posts
    440

    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.

  14. #59
    Join Date
    Jan 2013
    Posts
    32

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

    It is hard enough for me to understand you people in english about c++, understanding a book in english about c++.... i dont think i am capeble of that
    (english is my second language)

  15. #60
    Join Date
    Jan 2013
    Posts
    32

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

    when i try to find out about something specific i go to youtube and look at Buckys C++ Programming Tutorials , he talk about them kinda sorta understandebly to me with examples

Page 4 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured