Loops and Vectors
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Loops and Vectors

  1. #1
    Join Date
    Jul 2014
    Posts
    15

    Loops and Vectors

    How would I make a loop that would simultaneously compute both the max and min of a vector?

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,069

    Re: Loops and Vectors

    Quote Originally Posted by cloud125 View Post
    How would I make a loop that would simultaneously compute both the max and min of a vector?
    You need two variables, one to hold the max value, the other to hold the min value.
    Set them each to the first element in the vector.
    Iterate the vector replacing the values in the variables when appropriate.

  3. #3
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,335

    Re: Loops and Vectors

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center