抽奖
2025-06-11 19:07:05
发布于:北京
抽奖器
#include <iostream>
#include <string>
#include <random>
#include <vector>
#include <algorithm>
stdstring generateLotteryNumber() {
stdrandom_device rd;
stdmt19937 gen(rd());
stduniform_int_distribution<> dis(0, 9);
stdvector<int> redBalls;
while (redBalls.size() < 3) {
int num = dis(gen);
if (stdfind(redBalls.begin(), redBalls.end(), num) == redBalls.end()) {
redBalls.push_back(num);
}
}
int blueBall = dis(gen);
std::string redPart;
for (int num : redBalls) {
redPart += std::to_string(num);
}
std::string bluePart = std::to_string(blueBall);
return redPart + bluePart;
}
int main() {
stdstring lotteryNumber = generateLotteryNumber();
stdcout << "生成的双色球号码是:" << lotteryNumber << stdendl;
stdcout << "(前3位为红球,最后1位为蓝球)" << std::endl;
return 0;
}
加入团队后才能抽。
有1~7等奖,不同奖不同等级
链接描述
这里空空如也
有帮助,赞一个