Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std ;
- int main() {
- // 跑馬燈上的文字
- string str = "滾滾長江東逝水,浪花淘盡英雄。"
- "是非成敗轉頭空:青山依舊在,幾度夕陽紅。" ;
- int i ;
- // 列印的起始位置
- int p = 0 ;
- while ( 1 ) {
- // 由p 位置起循環列印整行
- for ( i = 0 ; i < str.size() ; i+=2 ) {
- cout << str[(p+i)%str.size()] << str[(p+i+1)%str.size()] <<flush ;
- }
- // 程式休息一秒
- _sleep(1000) ;
- // 將鍵盤游標重到行首
- cout << "\r" ;
- p-=2 ;
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment