很简单,也很少。代码如下:
#include<iostream>
#include<windows.h>
using namespace std;
void GotoXY(int x, int y) // 移动
{
HANDLE hout; //屏幕尺寸 变量
COORD coord={
x,y}; //光标坐标 变量 光标x标 光标y标
hout=GetStdHandle(STD_OUTPUT_HANDLE); //获得屏幕尺寸
SetConsoleCursorPosition(hout,coord); //移动光标
}
int main()
{
cout<<0;
GotoXY(0,1);
system("pause");
system("cls");
int x=0;
for (int i=1;i<=40;i++)
{
GotoXY(x,0);
cout<<" ";
x++;
GotoXY(x,0);
cout<<0;
Sleep(15);
}
int y=0;
for (int i=1;i<=15;i++)
{
GotoXY(x,y);
cout<<" ";
y++;
GotoXY(x