Telegram Group & Telegram Channel
Что такое std::sample?

std::sample — алгоритм который позволяет брать случайный элемент из диапазона. Был введён в C++ 17.

Описание его функциональности:

1. Выбирает n уникальных элементов случайным образом из входного диапазона
2. Копирует выбранные элементы в выходной диапазон
3. Сохраняет относительный порядок выбранных элементов

Синтаксис:

std::sample(input_begin, input_end, output_begin, n, generator);

- input_begin и input_end — итераторы входного диапазона
- output_begin — итератор выходного диапазона
- n — количество элементов для выборки
- generator — генератор случайных чисел

➡️ @cpp_geek



tg-me.com/cpp_geek/276
Create:
Last Update:

Что такое std::sample?

std::sample — алгоритм который позволяет брать случайный элемент из диапазона. Был введён в C++ 17.

Описание его функциональности:

1. Выбирает n уникальных элементов случайным образом из входного диапазона
2. Копирует выбранные элементы в выходной диапазон
3. Сохраняет относительный порядок выбранных элементов

Синтаксис:

std::sample(input_begin, input_end, output_begin, n, generator);

- input_begin и input_end — итераторы входного диапазона
- output_begin — итератор выходного диапазона
- n — количество элементов для выборки
- generator — генератор случайных чисел

➡️ @cpp_geek

BY C++ geek




Share with your friend now:
tg-me.com/cpp_geek/276

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.

Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.

telegram from es


Telegram C++ geek
FROM USA