Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. summing the values of 2 vectors.
Forum Updated to NodeBB v4.3 + New Features

summing the values of 2 vectors.

Scheduled Pinned Locked Moved Solved C++ Gurus
3 Posts 2 Posters 625 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Natural_Bugger
    wrote on last edited by Natural_Bugger
    #1

    hello,

    how do you sum the values of 2 vectors.
    for example:

    // example A
    3 1    // vector A
    5 2 8  // vector B
    

    or

    example B
    5 2 8  // vector A
    3 1    // vector B
    

    in the case of example A
    3 + 5 =
    3 + 2 =
    3 + 8 =
    1 + 5 =
    1 + 2 =
    1 + 8 =

    in the case of example B
    5 + 3
    5 + 1
    2 + 3
    2 + 1
    8 + 3
    8 + 1

    what kind of looping mechanism would it take?

    JonBJ 1 Reply Last reply
    0
    • N Natural_Bugger

      hello,

      how do you sum the values of 2 vectors.
      for example:

      // example A
      3 1    // vector A
      5 2 8  // vector B
      

      or

      example B
      5 2 8  // vector A
      3 1    // vector B
      

      in the case of example A
      3 + 5 =
      3 + 2 =
      3 + 8 =
      1 + 5 =
      1 + 2 =
      1 + 8 =

      in the case of example B
      5 + 3
      5 + 1
      2 + 3
      2 + 1
      8 + 3
      8 + 1

      what kind of looping mechanism would it take?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Natural_Bugger
      Outer for loop on vector A, inner for loop on vector B, for the order you specify. Resulting in 6 answers in each example.

      N 1 Reply Last reply
      3
      • JonBJ JonB

        @Natural_Bugger
        Outer for loop on vector A, inner for loop on vector B, for the order you specify. Resulting in 6 answers in each example.

        N Offline
        N Offline
        Natural_Bugger
        wrote on last edited by
        #3

        @JonB

        yeah, i got it already.
        i choose the smallest vector for the outer loop and and biggest for the inner.

        but thnx anyway.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved