progress_bar
The corresponding codes#include#include typedef long long int TYPE_INDEX; void progress_bar(TYPE_INDEX current, TYPE_INDEX total, std::string name){ if (current < total - 1){ std::cout << "r " << name << " progress: [" << current * 100 / (total - 1) << "%]"; } else { std::cout << "r " << name << " progress completed: [100%]"; } TYPE_INDEX show_num = current * 20 / total; for (TYPE_INDEX i = 0; i < show_num; i++){ std::cout << "█"; } } int main() { TYPE_INDEX total{100000}; for (TYPE_INDEX i = 0; i < total; i++) { progress_bar(i, total, "test"); } std::cout << std::endl; return 0; }



