gpt4 book ai didi

c++ - 如何使用 C++ 显示 "Loading..."并使用 3 个点进行动画处理?

转载 作者:行者123 更新时间:2023-11-28 00:44:21 29 4
gpt4 key购买 nike

您可能在许多地方看到过“正在加载...”,其中有 3 个点(或更多),即。 “...”,先一个一个出现,然后所有的点都显示出来,然后消失,再一个一个出现(所以,总共2次)。

详细说明:-

第 1 阶段:

Loading.

第 2 阶段:

Loading..

第 3 阶段:

Loading...

Then, it repeats second time! and then terminate!

所以,为此我准备了一个C++程序,它的源代码是:

#include <iostream.h>
#include <time.h>
#include<dos.h>
int main()
{
cout << "Loading";
cout.flush();
for (;;) {
for (int i = 0; i < 3; i++) {
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
}

return 0;
}

这个程序没有终止。它不会停止!我如何编辑它以使其终止?

请发布 Turbo C++ 编译器 支持的代码,因为我不太了解 ANSI C++!! :P

各位大侠,帮帮我好吗? :)

提前致谢! :)

最佳答案

为什么不使用退格键删除这些点?

#include <iostream>
#include <ctime>

using namespace std;

int main()
{
cout << "Loading";
cout.flush();
for (;;) {
for (int i = 0; i < 3; i++) {
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
}

return 0;
}

关于c++ - 如何使用 C++ 显示 "Loading..."并使用 3 个点进行动画处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17132151/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com