int main() { Rand_int rnd {0,30}; std::vector<int> histogram(31); for(int i = 0; i!=200; ++i) ++histogram[rnd()]; for(int i = 0; i!=histogram.size(); ++i){ std::cout << i << '\t'; for(int j=0; j!=histogram[i]; ++j) std::cout << '*'; std::cout<< std::endl; } //Comparison of randoms. auto ndist = std::bind(std::normal_distribution<>{0,30}, std::default_random_engine{}); std::vector<int> histogram2(31); for(int i = 0; i!=200; ++i) ++histogram2[rnd()]; for(int i = 0; i!=histogram2.size(); ++i){ std::cout << i << '\t'; for(int j=0; j!=histogram2[i]; ++j) std::cout << '*'; std::cout<< std::endl; } }
static int testcolorproc2() { unsigned int result[256] = {0}; unsigned char bitmap[5*4] = { 1, 2, 3, 4, 42, 1, 2, 3, 4, 42, 5, 5, 5, 5, 42, 0, 0, 9, 9, 42 }; histogram2(bitmap, 0, 4, 5, 4, result); int i; ASSERTEQUAL(result[0], 1); ASSERTEQUAL(result[1], 2); ASSERTEQUAL(result[2], 0); ASSERTEQUAL(result[5], 2); ASSERTEQUAL(result[42], 0); return 0; }