C++完成相似延時停留的打字後果。本站提示廣大學習愛好者:(C++完成相似延時停留的打字後果)文章只能為提供參考,不一定能成為您想要的結果。以下是C++完成相似延時停留的打字後果正文
可以或許定位光標地位,轉變屏幕設置
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <stdlib.h> //system函數所需頭文件
#define stoptimelong 500 //Sleep函數以毫秒為單元,Sleep(500);表現停半秒
using namespace std;
//跳到屏幕指定坐標
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"); //挪用掌握台色彩治理敕令,可以轉變屏幕和字體的色彩
printf("歡");
Sleep(stoptimelong);
printf("迎");
Sleep(stoptimelong);
printf("來");
Sleep(stoptimelong);
printf("到");
system("color 19");
Sleep(stoptimelong);
printf("計");
Sleep(stoptimelong);
printf("算");
Sleep(stoptimelong);
printf("機");
system("color 37");
Sleep(stoptimelong);
printf("冒");
Sleep(stoptimelong);
printf("險");
system("color 46");
Sleep(stoptimelong);
printf("世");
Sleep(stoptimelong);
printf("界");
Sleep(stoptimelong);
printf("!");
Sleep(stoptimelong);
cout<<endl;
getch();
return 0;
}
演示圖片
以上所述就是本文的全體內容了,願望可以或許對年夜家進修C++有所贊助。