給你參考
[C++] 純文本查看 復制代碼 #include<cstdlib>
#include<iostream>
#include<string>
#include<deque>
#include<algorithm>
#include<Windows.h>
#define BUFFERMAX 80
//不用 using namespace std;
//就要一個一個列舉要用std的是哪一些
using std::string;
using std::cout;
using std::deque;
int main()
{
deque<char> show;
string res = "Hello World!";
//補滿80字
while( res.size() < BUFFERMAX )
res.push_back(' ');
//複製到 deque(雙向佇列) show
copy( res.begin() , res.end() , std::back_inserter(show) );
while(true)
{
system("cls");
//顯示 有C++11的寫法 但怕你不會編譯,舊式寫法也支援
//use -std=c++11 to enable C++11
#if __cplusplus < 201103LL
for(int p=0;p<show.size();++p){//C++
char i =show[p];
#else
for(char &i : show){//C++11
#endif
cout<<i;
}
//把最後一個字複製到前面來
show.push_front(show.back());
//把最後一個字刪除
show.pop_back();
Sleep(150);
}
}
|