小球
2026-04-17 13:53:14
发布于:浙江
以下是一段小球滚动动画
#include <iostream>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
int main() {
const int t=10;
const int s=500;
for(int i=0;i<t;i++) {
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout<<"【5秒小球移动动画】"<<endl;
cout<< "------------------------"<<endl;
for(int j=0;j<i;j++){
cout<< " ";
}
cout<<"●"<<endl;
cout<<"------------------------"<<endl;
cout<<"剩余时间:"<<(5-i*0.5)<<"秒"<<endl;
#ifdef _WIN32
Sleep(s);
#else
usleep(s*1000);
#endif
}
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "动画播放完毕(总时长约5秒)!"<<endl;
}
全部评论 1
o
2026-04-08 来自 浙江
1
















有帮助,赞一个