Choose m evenly spaced elements from a sequence of length n

后端 未结 5 1478
再見小時候
再見小時候 2020-12-09 12:24

I have a vector/array of n elements. I want to choose m elements.

The choices must be fair / deterministic -- equally many from each subsection.

With m=10, n

5条回答
  •  误落风尘
    2020-12-09 13:17

    Use a loop (int i=0; i < m; i++)

    Then to get the indexes you want, Ceil(i*m/n).

提交回复
热议问题