CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Join Date
    Feb 2009
    Posts
    35

    Re: Newbie learning sorting algorithms and arrays

    yea i probably didn't, thanks for your help

  2. #17
    Join Date
    Feb 2009
    Posts
    35

    Re: Newbie learning sorting algorithms and arrays

    additional requirement is to calculate median but i have been hitting always on the same point, i cant think of any logic to add this to my program, anyone have ideas how to get these from the data?
    Last edited by peste19; April 10th, 2009 at 12:43 PM.

  3. #18
    Join Date
    Feb 2009
    Posts
    35

    Re: Newbie learning sorting algorithms and arrays

    bump

  4. #19
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Newbie learning sorting algorithms and arrays

    Quote Originally Posted by peste19 View Post
    additional requirement is to calculate mode,median but i have been hitting always on the same point, i cant think of any logic to add this to my program, anyone have ideas how to get these from the data?
    Learn to write functions, and then just call them with the appropriate arguments.
    Code:
    double CalculateMean(double *yourData, int numberOfData)
    {
       // you fill this in
    }
    
    double CalculateMedian(double *yourData, int numberOfData)
    {
       // you fill this in
    }
    
    double CalculateMode(double *yourData, int numberOfData)
    {
       // you fill this in
    }
    
    
    int main()
    {
     //....
       cout << "The mean is " << CalculateMean(grade, 12) << "\n";
    //.. etc...
    }
    Regards,

    Paul McKenzie

  5. #20
    Join Date
    Feb 2009
    Posts
    35

    Re: Newbie learning sorting algorithms and arrays

    I know how to create the module, my issue is i just cant make it work in my head how to write the statement

  6. #21
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Newbie learning sorting algorithms and arrays

    Quote Originally Posted by peste19 View Post
    I know how to create the module, my issue is i just cant make it work in my head how to write the statement
    It isn't a statement.

    First, do not edit your original post about what you need to do. This makes my post to you lose its meaning. What exactly do you need to compute? Whatever that is, how do you do it with pencil and paper?

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; April 10th, 2009 at 02:34 PM.

  7. #22
    Join Date
    Feb 2009
    Posts
    35

    Re: Newbie learning sorting algorithms and arrays

    delete got it
    Last edited by peste19; April 12th, 2009 at 03:05 PM.

Page 2 of 2 FirstFirst 12

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