移动书写位置练习C++

移动书写位置练习C++,第1张

#include 
#include 
#include 
#include 
#include       
#include          
#include 
using namespace std;
void gotoxyzimu(int x, int y) {//位置函数(行为x 列为y)字母
	COORD pos;
	pos.X=y;
	pos.Y=x;
	SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE),pos);
}
void gotoxyhanzi(int x, int y) {//位置函数(行为x 列为y)汉字(兼容字母但有空格偏位)
	COORD pos;
	pos.X=y*2;
	pos.Y=x;
	SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE),pos);
}
int main()
{
    cout<<"##########\n";
    cout<<"##########\n";
    cout<<"##########\n";
    cout<<"##########\n";
    cout<<"##########\n";
    cout<<"##########\n";
    cout<<"##########\n";
    for (int i = 1; i <= 3; i++) {
        gotoxyzimu(1,i);
        cout<<"h";
        Sleep(1000);
        gotoxyzimu(2,i);
        cout<<"e";
        Sleep(1000);
        gotoxyzimu(3,i);
        cout<<"l";
        Sleep(1000);
        gotoxyzimu(4,i);
        cout<<"l";
        Sleep(1000);
        gotoxyzimu(5,i);
        cout<<"o";
        Sleep(1000);
        gotoxyhanzi(1,i);
        cout<<"哈";
        Sleep(1000);
        gotoxyhanzi(2,i);
        cout<<"喽";
        Sleep(1000);
        gotoxyhanzi(3,i);
        cout<<"啊";
        Sleep(1000);
        gotoxyhanzi(4,i);
        cout<<"喽";
        Sleep(1000);
        gotoxyhanzi(5,i);
        cout<<"哈";
        Sleep(1000);
    }
    Sleep(10000);
    return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1330671.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-12
下一篇 2022-06-12

发表评论

登录后才能评论

评论列表(0条)

保存