#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#define map_mode "■"
void HideCursor() //隐藏光标
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hOut, &cci);
}
void GotoXY(int x, int y) //光标移动到x,y位置
{
COORD pos = { x,y };
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);// 获取标准输出设备句柄
SetConsoleCursorPosition(hOut, pos); //两个参数分别是指定哪个窗体,具体位置
}
void DrawRectangle(int x1, int y1, int x2, int y2)
{
int i;
for (i = x1; i < x2 ; i += 2) {
GotoXY(i, y1);
printf(map_mode);
GotoXY(i, y2);
printf(map_mode);
}
for (i = y1; i < y2 + 1; i++) {
GotoXY(x1, i);
printf(map_mode);
GotoXY(x2, i);
printf(map_mode);
}
}
int main()
{
int x1 = 10, y1 = 1, x2 = x1 + 26 + 2, y2 = y1 + 20;
int i;
char c;
system("mode con cols=50 lines=25");
system("color 0A"); //背景黑色 字体绿色
HideCursor();
DrawRectangle(x1, y1, x2, y2);
GotoXY(x1 + 2, y2 - 1);
printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
do{
c = rand() % 26 + 'A';
for (i = y1 + 1; i < y2 - 1; i = i + 1)
{
GotoXY(x1 + c - 'A' + 2, i);
printf("%c", c);
Sleep(100);
GotoXY(x1 + c - 'A' + 2, i);
printf(" ");
}
GotoXY(x1 + c - 'A' + 2, i);
printf("=");
Sleep(200);
GotoXY(x1 + c - 'A' + 2, i);
printf("%c", c);
} while (_kbhit() == 0);
return 0;
}
这个该怎么解决??