Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我了解如何在 C 中制作进度条(只需打印完成了多少,然后在打印之前刷新屏幕)。但是为此,我浪费了时间(使用进度条解决问题比没有进度条需要更多时间)。进度条是指已经完成的百分比。有什么解决办法吗?
如果它显着增加了您的运行时间,那么您可能过于频繁地写入标准输出。例如尝试类似的东西
for(i = 0; i < 1000000; i++) printf("\r%d",i);
对比
for(i = 0; i < 1000000; i++);
为了提高性能,您可以在经过这么多操作或经过一段时间后写入控制台。