编程语言
首页 > 编程语言> > C++内建函数对序列产生min到max的值进行随机化

C++内建函数对序列产生min到max的值进行随机化

作者:互联网

#include <algorithm>

void GetRandomUniqueSequence(int vMin, int vMax, std::vector<int>& voResultRandomUniqueSequence)
{
	if (vMin > vMax)
	{
#ifdef OUTPUTDEBUG
		std::cout << "vMin > vMax, Error !" << std::endl;
#endif
		return;
	}
	else
	{
		voResultRandomUniqueSequence.clear();

		for (int i = vMin; i < vMax; i++)
		{
			voResultRandomUniqueSequence.push_back(i);
		}
		std::random_shuffle(voResultRandomUniqueSequence.begin(), voResultRandomUniqueSequence.end());
	}
}

 

标签:std,cout,vMin,min,int,max,随机化,vMax
来源: https://blog.csdn.net/Tokyo_2024/article/details/112852572