/**/
#include <iostream>
#include <vector>
#include <random>
#include <limits>
#include <random>
typedef std::vector < std::uint8_t > DType;
DType MakeVector(std::size_t N,unsigned int S=0) {
std::minstd_rand mr(S);
DType R;
std::uniform_int_distribution<> UI(0, std::numeric_limits<std::uint8_t>::max());
for (std::size_t i = 0; i < N; i++) {
R.push_back(UI(mr));
}
return R;
}
template<class T>
bool ShowBitLH(const T& N) {
for (std::size_t i = 0; i < std::numeric_limits<T>::digits; i++) {
std::cout << ((N & (1 << i)) > 0 ? 1 : 0);
}
return true;
}
template<class T>
bool ShowBitHL(const T& N) {
for (std::int64_t i = std::numeric_limits<T>::digits-1; i >=0 ; i--) {
std::cout << (((N & (1ll << i)) > 0) ? 1 : 0);
}
return true;
}
int main() {
{
//std::uint8_t N = 127;
//ShowBitHL(N);
}
DType R = MakeVector(16);
for (auto& o : R) {
std::cout << '[' << (int)o << ':';
ShowBitHL(o);
std::cout << ']'<<' ';
}
std::cout << ' ' << std::endl;
return 0;
}
/**/
/** /
#include <iostream>
#include <vector>
#include <random>
#include <limits>
#include <random>
#include <cstddef>
//c++17
typedef std::vector < std::byte > DType;
DType MakeVector(std::size_t N,unsigned int S=0) {
std::minstd_rand mr(S);
DType R;
std::uniform_int_distribution<> UI(0, std::numeric_limits<std::uint8_t>::max());
for (std::size_t i = 0; i < N; i++) {
R.push_back(std::byte(UI(mr)));
}
return R;
}
template<class T>
bool ShowBitLH(const T& N) {
for (std::size_t i = 0; i < std::numeric_limits<T>::digits; i++) {
std::cout << ((N & (1 << i)) > 0 ? 1 : 0);
}
return true;
}
template<class T>
bool ShowBitHL(const T& N) {
for (std::int64_t i = std::numeric_limits<T>::digits-1; i >=0 ; i--) {
std::cout << (((N & (1ll << i)) > 0) ? 1 : 0);
}
return true;
}
int main() {
{
//std::uint8_t N = 127;
//ShowBitHL(N);
}
DType R = MakeVector(16);
for (auto& o : R) {
std::cout << '[' << std::to_integer<std::uint16_t>(o) << ':';
ShowBitHL(std::to_integer<std::uint8_t>(o));
std::cout << ']'<<' ';
}
std::cout << ' ' << std::endl;
return 0;
}
/**/