数组统计直方图小技巧

int main()
{
    std::cout << "Hello World!\n";
	unsigned short histogram[65535];

	memset(histogram, 0, 65535 * sizeof(unsigned short));

	for (size_t i = 0; i < 65535; i++)
	{
		if (i%3==0)
		{
			++histogram[2];
		}
		if (i%4==0)
		{
			++histogram[1];
		}
		//std::cout<<++histogram[i]<<std::endl;
	}
	
	for (size_t i = 0; i < 4; i++)
	{
		std::cout << histogram[i] << std::endl;
	}
}

输出结果
数组统计直方图小技巧

上一篇:VS报错strcpy不安全


下一篇:Codeforces 1631 F. Flipping Range —— 位置取模的DP,有丶东西