C++實(shí)現(xiàn)類似延時(shí)停頓的打字效果
更新時(shí)間:2015年03月31日 10:00:13 投稿:hebedich
這篇文章主要介紹的是使用C++實(shí)現(xiàn)類似延時(shí)停頓的打字效果的代碼,非常的簡單,推薦給大家,有需要的小伙伴可以參考下。
能夠定位光標(biāo)位置,改變屏幕設(shè)置
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <stdlib.h> //system函數(shù)所需頭文件
#define stoptimelong 500 //Sleep函數(shù)以毫秒為單位,Sleep(500);表示停半秒
using namespace std;
//跳到屏幕指定坐標(biāo)
void gotoxy(int x,int y)
{ CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
csbiInfo.dwCursorPosition.X = x;
csbiInfo.dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);
}
int main(void)
{ int x=14, y=5;
gotoxy(x, y);
printf("你好!");
Sleep(stoptimelong);
system("color 10"); //調(diào)用控制臺(tái)顏色管理命令,可以改變屏幕和字體的顏色
printf("歡");
Sleep(stoptimelong);
printf("迎");
Sleep(stoptimelong);
printf("來");
Sleep(stoptimelong);
printf("到");
system("color 19");
Sleep(stoptimelong);
printf("計(jì)");
Sleep(stoptimelong);
printf("算");
Sleep(stoptimelong);
printf("機(jī)");
system("color 37");
Sleep(stoptimelong);
printf("冒");
Sleep(stoptimelong);
printf("險(xiǎn)");
system("color 46");
Sleep(stoptimelong);
printf("世");
Sleep(stoptimelong);
printf("界");
Sleep(stoptimelong);
printf("!");
Sleep(stoptimelong);
cout<<endl;
getch();
return 0;
}
演示圖片

以上所述就是本文的全部內(nèi)容了,希望能夠?qū)Υ蠹覍W(xué)習(xí)C++有所幫助。
您可能感興趣的文章:
- js+css實(shí)現(xiàn)打字效果
- C++實(shí)現(xiàn)的打字母游戲示例
- javascript實(shí)現(xiàn)自動(dòng)輸出文本(打字特效)
- 基于Css3和JQuery實(shí)現(xiàn)打字機(jī)效果
- JavaScript實(shí)現(xiàn)打字效果的方法
- JavaScript模擬實(shí)現(xiàn)鍵盤打字效果
- javascript游戲開發(fā)之《三國志曹操傳》零部件開發(fā)(三)情景對話中仿打字機(jī)輸出文字
- JavaScript打字小游戲代碼
- javascript 打字效果的文字特效
- javascript 打字游戲?qū)崿F(xiàn)代碼
- javascript之textarea打字機(jī)效果提示代碼推薦
- C語言制作簡易金山打字通功能的代碼
相關(guān)文章
關(guān)于C++靜態(tài)成員函數(shù)訪問非靜態(tài)成員變量的問題
靜態(tài)成員函數(shù)不能訪問非靜態(tài)成員,這是因?yàn)殪o態(tài)函數(shù)屬于類而不是屬于整個(gè)對象,靜態(tài)函數(shù)中的 member可能都沒有分配內(nèi)存。靜態(tài)成員函數(shù)沒有隱含的this自變量。所以,它就無法訪問自己類的非靜態(tài)成員2013-10-10
C/C++的浮點(diǎn)數(shù)在內(nèi)存中的存儲(chǔ)方式分析及實(shí)例
這篇文章主要介紹了C/C++的浮點(diǎn)數(shù)在內(nèi)存中的存儲(chǔ)方式分析及實(shí)例的相關(guān)資料,需要的朋友可以參考下2016-11-11

