矢量的元素太多.组合程序
Too much elements of vector . Combinations program
大家好
我正在为乐透统计做一个项目,基本上它有类"kombinacije4",它具有第一个数字第二个数字第三个数字第四个数字的属性以及它上次出现的日期和时间以及组合出现的次数。
class kombinacije4 {
public:
Date date;
Time time;
int first;
int second;
int third;
int fourth;
int howMuchRoundsDidntShowedUp;
int howMuchTimesAppeared;
void GetCombination(int, int, int, int);
void GetCombinationsAfterRound(int);
};
然后我有这些元素的向量
std::vector<kombinacije4> fourties;
我非常快速和很好地初始化了这个向量,但是当我想更改这些属性时,例如它上次出现的日期和时间或它出现的数量时,我遇到了问题,因为有 80 个数字,他们在一轮中绘制了 20 个数字。从这 20 个数字中,我必须将 4 个数字组合在一起,并在fourties
中找到它们并更改它们的属性。七百次。因为有700发子弹。有没有人知道如何通过他们的值直接访问。也许std::find
可以做点什么?显然我有时间限制问题。
以另一种方式做这个程序的任何想法?
for(auto i=round.begin();i!=round.end();i++){
for(auto j=i+1;j!=round.end();j++){
for(auto k=j+1;k!=round.end();k++){
for(auto l=k+1;l!=round.end();l++){
for(auto p=fourties.begin();p!=fourties.end();p++){
-if-statement
}
}
}
}
}
Obviously this block is going to pass 3 million times through the vector of million and half elements
谢谢!
要访问向量内对象的成员,您应该只使用 myobject[iterator].membername
.
例如:
for (auto p = fourties.begin(); p!= fourties.end(); p++)
{
if (fourties.at[p].first == "your data" &&
fourties.at[p].second == "your data" &&
fourties.at[p].third == "your data" &&
fourties.at[p].fourth == "your data")
{
fourties.at[p].date = 'your data';
fourties.at[p].time = 'your data';
}
}
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++,系统无法执行指定的程序
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 如何将独立的 c 应用程序组合到 c++ 应用程序中?
- 找不到如何创建使用指针、字符和 for 函数组合的程序
- C++对象文件和程序文件组合编译的 Bashrc 别名
- 如何指示/打印基于斐波那契数字的程序的不同组合
- 制作需要接受字母和数字组合的密码类型程序
- 生成k数字的NCK组合的程序从1到n不等
- 在自定义组合框下拉列表控件上等待超过5秒会导致win32 C++应用程序在Windows7中挂起
- 我用c ++编写了组合程序,但没有输出,任何人都可以说出原因吗?
- 我可以将一个可执行文件与另一个可执行文件(Windows 服务程序)组合在一起,并将该程序作为逻辑服务运行吗?
- 密码破解程序组合程序
- IM 创建一个 C++ 程序,其中用户可以尝试 2 次尝试密码用户名组合.如果他们无法获得它,他们的程序就会停止
- 我的聚合、关联和组合关系在这个C++程序中不起作用
- 这是我的程序编写每十亿个组合的一种更有效的方式
- 如何组装、链接和编译c++、NASM文件和.o驱动程序的组合
- 矢量的元素太多.组合程序
- 将不同的线程方法组合到Windows窗体应用程序中