[ create a new paste ] login | about

Link: http://codepad.org/ztV3gsla    [ raw code | output | fork ]

C++, pasted on Dec 27:
#include <string>
#include <locale>
#include <bitset>

#include <iostream>

void find(const std::string& s)
{
	std::string::size_type curr = 0, next;
	for (; (next = s.find_first_of("01", curr)) != std::string::npos; )
	{
		curr = s.find_first_not_of("01", next);
		const std::bitset<64> b(s.substr(next, curr-next));
		std::cout << b.to_ulong() << std::endl;
	}
}

int main()
{
	setlocale(LC_ALL, "");

	const std::string s = "abc1100def00112110zzz011pp1";
	find(s);

	return 0;
}


Output:
1
2
3
4
5
12
3
6
3
1


Create a new paste based on this one


Comments: