学着写个玩玩
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
HANDLE hOut;
unsigned int cc[32]= {0};
unsigned int ch[32]=
{
0x00080000,0x00180400,0x00381C00,0x00180C00,
0x18180C00,0x3FFFFFFE,0x00180C00,0x00180C00,
0x00180C00,0x00180C00,0x20000008,0x7FFFFFF8,
0x7000000C,0x1000000C,0x0900000E,0x03800006,
0x07FFFFE0,0x0001C000,0x0001C000,0x0001C000,
0x0081C000,0x01C1C000,0x03FFFFC0,0x0001C000,
0x0011C000,0x0061C000,0x01C1C000,0x01C1C000,
0x1181C000,0x3901C000,0x7FFFFFFE,0x00000004
};
int _BitTest(unsigned int *a, int n, int bit)
{
return (a[n]>>bit)&1;
}
void _BitSet(unsigned int *a, int n, int bit)
{
a[n] |= 1<<bit;
}
SHORT _rand(SHORT N)
{
return (SHORT)((double)rand()/(RAND_MAX+1.0)*N);
}
void _saych(SHORT x, SHORT y, char c)
{
COORD pos = {x, y};
SetConsoleCursorPosition(hOut, pos);
putchar(c);
}
void _say(SHORT i, SHORT j)
{
if (_BitTest(ch,i,j))
{
if (!_BitTest(cc,i,j))
_saych(j*2, i, _rand(27)+64);
}
else
_saych(j*2, i, ' ');
Sleep(1);
}
main()
{
srand((unsigned)time(0));
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(hOut, &cursor_info);
SHORT i, j, k;
for (k=2000; k>0; --k)
{
i = _rand(32);
j = _rand(32);
_BitSet(cc, i, j);
_saych(j*2, i, _rand(27)+64);
Sleep(1);
}
for (k=2000; k>0; --k)
_say(_rand(32), _rand(32));
for (i=0; i<32; ++i)
for (j=0; j<32; ++j)
_say(i, j);
getch();
cursor_info.bVisible = 1;
SetConsoleCursorInfo(hOut, &cursor_info);
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
HANDLE hOut;
unsigned int cc[32]= {0};
unsigned int ch[32]=
{
0x00080000,0x00180400,0x00381C00,0x00180C00,
0x18180C00,0x3FFFFFFE,0x00180C00,0x00180C00,
0x00180C00,0x00180C00,0x20000008,0x7FFFFFF8,
0x7000000C,0x1000000C,0x0900000E,0x03800006,
0x07FFFFE0,0x0001C000,0x0001C000,0x0001C000,
0x0081C000,0x01C1C000,0x03FFFFC0,0x0001C000,
0x0011C000,0x0061C000,0x01C1C000,0x01C1C000,
0x1181C000,0x3901C000,0x7FFFFFFE,0x00000004
};
int _BitTest(unsigned int *a, int n, int bit)
{
return (a[n]>>bit)&1;
}
void _BitSet(unsigned int *a, int n, int bit)
{
a[n] |= 1<<bit;
}
SHORT _rand(SHORT N)
{
return (SHORT)((double)rand()/(RAND_MAX+1.0)*N);
}
void _saych(SHORT x, SHORT y, char c)
{
COORD pos = {x, y};
SetConsoleCursorPosition(hOut, pos);
putchar(c);
}
void _say(SHORT i, SHORT j)
{
if (_BitTest(ch,i,j))
{
if (!_BitTest(cc,i,j))
_saych(j*2, i, _rand(27)+64);
}
else
_saych(j*2, i, ' ');
Sleep(1);
}
main()
{
srand((unsigned)time(0));
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(hOut, &cursor_info);
SHORT i, j, k;
for (k=2000; k>0; --k)
{
i = _rand(32);
j = _rand(32);
_BitSet(cc, i, j);
_saych(j*2, i, _rand(27)+64);
Sleep(1);
}
for (k=2000; k>0; --k)
_say(_rand(32), _rand(32));
for (i=0; i<32; ++i)
for (j=0; j<32; ++j)
_say(i, j);
getch();
cursor_info.bVisible = 1;
SetConsoleCursorInfo(hOut, &cursor_info);
}