C++ Draw程序,分成两组

标签 c++ random containers iostream

我想做一个抽奖申请。我想输入用户名,直到输入“结束”,然后程序将它们分成两组。你能推荐一些例子吗?我不知道如何开始!如果可能的话,我想跨平台。如果不可能,我想要 Linux。

最佳答案

假设我正确理解了您的问题:

伪代码:

while the user is entering user names
    store the user name in a list

for half the number of items in the list
    remove a random item from the list
    add that item to a second list

这里是关于使用 STL 容器类的教程。您可能希望使用 std::list:http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html

关于C++ Draw程序,分成两组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3025151/

相关文章:

algorithm - 一组整数约束的随机解

c++ - 将 vector 的整数内容打印为字符串会导致段错误

c++ - C++中的鼠标点击位置

c++ - 如何创建 PCM 签名的 16 位 wav 文件

c++ - 将 C 样式字符串转换为整数数组

java - 如何在 Docker 上从 Java 调用 .Net Core 类

具有快速查找/插入/删除功能的循环缓冲区

c++ - 用文字初始化引用成员变量

c++ - 传递给函数的 Default_random_engine 提供可重复的结果

docker - 部署 nginx 的最佳实践