数组统计直方图小技巧
作者:互联网
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;
}
}
输出结果
标签:std,技巧,++,histogram,直方图,数组,i%,cout 来源: https://blog.csdn.net/XUDINGYI312/article/details/122453716