本文整理汇总了C++中Bits::find_next方法的典型用法代码示例。如果您正苦于以下问题:C++ Bits::find_next方法的具体用法?C++ Bits::find_next怎么用?C++ Bits::find_next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bits
的用法示例。
在下文中一共展示了Bits::find_next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
int
main (int argc, char *argv[])
{
overall.resize(NMAX + 1);
b1.resize(NMAX + 1);
b2.resize(NMAX + 1);
gen_admissible();
print_bitset(overall, 640);
mpz_class p_prev = 0, p = 3;
mpz_class max;
mpz_set_ui(max.get_mpz_t(), NMAX);
size_t pos = overall.find_first();
Bits pf;
pf.resize(1000);
while (pos != string::npos && p_prev < max)
{
mpz_swap(p_prev.get_mpz_t(), p.get_mpz_t());
mpz_nextprime(p.get_mpz_t(), p_prev.get_mpz_t());
//cout << "next prime: " << p << endl;
unsigned uip = mpz_get_ui(p.get_mpz_t());
while (pos != string::npos && pos + 1 < uip)
{
pf.set(uip - pos);
//cout << "pos: " << pos << ", total: " << total << endl;
pos = overall.find_next(pos);
}
}
unsigned total = 0;
for (size_t pos = pf.find_first(); pos != string::npos; pos = pf.find_next(pos))
{
total += pos;
}
cout << "total: " << total << endl;
return 0;
}
示例2:
void
print_bitset(Bits b, size_t size = 0)
{
if (size == 0)
size = b.size();
for (size_t pos = b.find_first(); pos < size && pos != string::npos; pos = b.find_next(pos))
{
std::cout << pos << ", ";
}
std::cout << std::endl;
}