1 打印百分比进度
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include<iostream> #include<Windows.h> //Sleep()所需头文件 #include <iomanip> //setw()等控制符所需头文件 using namespace std; int main() { int i = 0; cout << "n当前进度:"; while(i<=10000) { cout << "r";//回到行首位置 //输出宽度 6,保留两位小数 cout << setw(6) << fixed << setprecision(2) << (float)i / 100 << "%"; Sleep(5); i++; } cout << endl << endl; system("pause"); return 0; }
输出结果:
2 打印进度条,并以百分比显示、
代码:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include<iostream> #include<Windows.h> //Sleep()所需头文件 #include <iomanip> //setw()所需头文件 using namespace std; int main() { cout << "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100%" << endl; int i = 1; while (i <= 100) { cout << "bbbb"; cout << "|" << setw(3) << i << "%"; Sleep(150); i++; } cout << endl << endl; system("pause"); return 0; }
结果展示:
最后
以上就是怕孤独茉莉最近收集整理的关于C++:打印进度条,百分比显示的全部内容,更多相关C++:打印进度条内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复