CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 5 1234 ... LastLast
Results 1 to 15 of 69
  1. #1
    Join Date
    Jan 2013
    Posts
    32

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

    I need to make a programm (probably childs play to most of u)
    But i have no clue how to do it, so please help, i need it done really fast.

    The prgoramm is:
    Write a programm in C++ that finds a matrixs A[4][7], then the sums (by adding them togeter) of all the positive elements of the numbers in the matrix from the third column and all the columns to the right of it(one sum for each column). And the shows it on the screen.


    If anyone could quicky make me the programm i would be very greatfull.
    It is a part of my homework that i have to send in with in the hour AT max 2 hours and i have no clue how to do that part. Really need help


    Well i think i even got the matix down form this part, but i got no clue how to axess a column, so start multiplying them......

    right now form this part this is what i manuaged to make, but.. i can only make it get some random diagonal? i got no idea how to get to a column and sum the numbers up there?


    #include <stdio.h>
    #include <time.h>
    #include <stdlib.h>

    #define RIDU 4
    #define VEERGE 7
    #define MAX 150
    #define MIN 10

    int main (void)


    {



    int maatriks [RIDU] [VEERGE];
    int i,j;



    srand(time(NULL));



    for(i=0; i<RIDU; i++)

    {
    for(j=0; j<VEERGE; j++)
    {

    maatriks[i][j]=rand()%(MAX-MIN)+MIN;
    }
    }



    printf("Generated maatrx on:\n\n");

    for(i=0; i<RIDU; i++)
    {
    for(j=0; j<VEERGE; j++)
    {
    printf("%4d", maatriks[i][j]);
    }
    printf("\n\n");
    }



    printf("third column?\n\n");

    for(i=0; i<RIDU; i++)
    {
    for(j=0; j<VEERGE; j++)
    {
    if (i>=j) printf("%4d", maatriks[i][j]);
    }
    printf("\n");
    }













    return 0;
    }

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

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

    The third column corresponds to j = 2

    so there is no need to a a for loop with j in your code to print out the 3rd column.

  3. #3
    Join Date
    Jan 2013
    Posts
    32

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

    still dont understand how do i write a code that for example will that the third colum and sum up all the numbers there? Very greatfull for any help, i need to despretly get it done.

  4. #4
    Join Date
    Jan 2013
    Posts
    32

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

    With that i manuaged to get the last column of my matrix on the screen... (no clue how to generate anything in the middle on the screen alone), but how on earth can i get the programm to sum up all the numbers from that column now?


    printf("Last column\n");

    for(i=0; i<RIDU; i++)
    {
    for(j=0; j<VEERGE; j++)
    {
    if (j>5) printf("%4d", maatriks[i][j]);
    }
    printf("\n");
    }

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

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

    Please use the code tags when posting code so that it is easier to read and understand. Also you have posted to the wrong forum. This forum is regarding visual c++ programming where as your question relates to just c++ - which is for the 'c++ (non visual c++) forum'.
    Also as your question relates directly to homework, I would suggest that you read the FAQ

    http://forums.codeguru.com/showthrea...ork-assignment


    I doubt that any member will write the code for you. I did for one query before and was politely rebuked by other members!

    If you write the code yourself and then have a specific question about what you have written then you will probably receive help.

    To quote from the above FAQ

    The very purpose of your homework is to verify that you have understood a subject and are able to apply the learned knowledge to solving specific problems. By having someone else do the assignment for you, you are not only cheating at your teachers, but also at yourself, since you pretend (and perhaps even believe) to have acquainted knowledge and skills that you actually don't have.

  6. #6
    Join Date
    Jan 2013
    Posts
    32

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

    i am not asking your to write my entire code i am asking for help how to get over obsicales, and this whole thing i asked is just a tiny bit of it, i dont have any clue how i can add up the column numbers.
    And sry about the wrong place, i dont really know whats visual or none visual c++ coding.

    Also i dunno where your from, but where i live it is perfectly fine to get your code done using internet and finding or getting help from anywhere. We can even do it on our programming exam.

    Also, this is right now the last day i can do it, and i am NOT doing it at home, it is like an extra assigmnet to my homework, to get it done, i am in my class and my teacher is almost literally next to me, what our teacher says to that is basically " it dosnt matter if you KNOW how to do it right that second, what matters is that u can find out how from anywhere you like, and u will learn how to do it from that,
    Last edited by SwiftXShadow; January 16th, 2013 at 09:08 AM.

  7. #7
    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
    i am not asking your to write my entire code i am asking for help how to get over obsicales, and this whole thing i asked is just a tiny bit of it, i dont have any clue how i can add up the column numbers.
    And sry about the wrong place, i dont really know whats visual or none visual c++ coding.

    Also i dunno where your from, but where i live it is perfectly fine to get your code done using internet and finding or getting help from anywhere. We can even do it on our programming exam.
    The policy of this forum is not to write homework code for people. You don't learn anything by having somebody do your work for you, and where most of us are from, it would be regarded as cheating and dishonest.

    To add all numbers in a column, you need a loop and a counter.
    Initialize the counter to 0;
    Write a loop incrementing from 0 through the number of rows - 1.
    Use the incrementing variable for the to access the row of the matrix, and keep the column number constant.
    Inside the loop, add the value found at the row and column of your matrix to your counter.

  8. #8
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

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

    Basically, you ignored what I said. To get a particular column, you do not need
    to loop on j.

    j = 0 ... gives the first column
    j = 1 ... gives the second column

    etc.

    Code:
    j = 2;
    for(i=0; i<RIDU; i++)
    {
      printf("%4d", maatriks[i][j]);
    }
    printf("\n");

  9. #9
    Join Date
    Jan 2013
    Posts
    32

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

    not ignored, just coulnt understand....

  10. #10
    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
    not ignored, just coulnt understand....
    Replace j with a number. If you want the third column, maatriks[i][2]

  11. #11
    Join Date
    Jan 2013
    Posts
    32

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

    wow that was soo simple, cant imagine how basic my questions must look to you..... i was experimenting with massive ammounts of code to try to generate it somehow.

    But how can i make 1 colum sum up all its numbers?

  12. #12
    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 already explained that.

  13. #13
    Join Date
    Jan 2013
    Posts
    32

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

    ouuuu

    u mena this part

    j = 2;
    for(i=0; i<RIDU; i++)
    {
    printf("%4d", maatriks[i][j]);
    }
    printf("\n");

  14. #14
    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
    ouuuu

    u mena this part

    j = 2;
    for(i=0; i<RIDU; i++)
    {
    printf("%4d", maatriks[i][j]);
    }
    printf("\n");
    http://forums.codeguru.com/showthrea...99#post2100899

  15. #15
    Join Date
    Jan 2013
    Posts
    32

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

    Ummm i must be rly dumb and still dun get it, or i can put a sentance together to propelly tell you my question, hope u dont get too anoyed, you are a big big help.

    That piece of code gives me all the numbers in the colum like 54 234 21 52 in a line, which is good... but how do i sum them up. Like 54+234+21+52=361.
    Really sincere apologizes if i look like i am mocking your with stupid questions, but i really dont understand, and u have been a very very big help so far already.

Page 1 of 5 1234 ... 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