Files
easyx-mingw64-dev/zifuzhen.cpp
Steven Hobs d8ba288e1d init
2026-03-04 17:47:10 +08:00

48 lines
822 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 编译环境Visual C++ 6.0~2022EasyX_25.9.10
// https://easyx.cn
//
#include <graphics.h>
#include <time.h>
#include <conio.h>
int main()
{
// 设置随机种子
srand((unsigned) time(NULL));
// 初始化图形模式
initgraph(640, 480);
int x, y;
char c;
settextstyle(16, 8, _T("Courier")); // 设置字体
// 设置颜色
settextcolor(GREEN);
setlinecolor(BLACK);
for (int i = 0; i <= 479; i++)
{
// 在随机位置显示三个随机字母
for (int j = 0; j < 3; j++)
{
x = (rand() % 80) * 8;
y = (rand() % 20) * 24;
c = (rand() % 26) + 65;
outtextxy(x, y, c);
}
// 画线擦掉一个像素行
line(0, i, 639, i);
Sleep(10); // 延时
if (i >= 479) i = -1;
if (_kbhit()) break; // 按任意键退出
}
// 关闭图形模式
closegraph();
return 0;
}