编程知识 cdmana.com

C/C++ 小数作为循环步长

实现

#include <iostream>

int main()
{
    
	const float stepsize = 0.3;
	for (int i = 0; i <= 100 / stepsize; ++i)
	{
    
		const double a = i * stepsize;
		std::cout << a << std::endl;
	}
}

版权声明
本文为[Dorthyn]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Dorthyn/article/details/126154278

Scroll to Top