随便写的O__O"!!#include<stdio.h>
#include<windows.h>
void sleep_peony();//可以直接用Sleep()代替
int main()
{
int f[9][9];
int s[9][9];
int i, j, t = 0;
for (i = 0; i < 9; i++)
{
for (j = 0; j < 9; j++)
{
f[i][j] = 1;
}
}
for (i = 1; i<9; i = i + 2)
{
f[i][0] = 0;
}
for (i = 0; i<9; i++)
{
if (f[i][0])
{
for (j = 1; j<9; j += 2)
{
f[i][j] = 0;
}
}
else
{
for (j = 2; j<9; j += 2)
{
f[i][j] = 0;
}
}
}
for (i = 0; i < 9; i++)
{
for (j = 0; j < 9; j++)
{
if (f[i][j])
{
s[i][j] = 0;
}
else
{
s[i][j] = 1;
}
}
}
while (1)
{
system("cls");
if (t)
{
for (i = 0; i<9; i++)
{
for (j = 0; j<9; j++)
{
printf("%-2d", f[i][j]);
}
printf("\n");
}
t = 0;
}
else
{
for (i = 0; i<9; i++)
{
for (j = 0; j<9; j++)
{
printf("%-2d", s[i][j]);
}
printf("\n");
}
t = 1;
}
sleep_peony(1000);
}
return 0;
}
void sleep_peony(long time)
{
HANDLE timehandle;
LARGE_INTEGER sleeptime;
MSG Msg;
LPHANDLE handle;
handle = &timehandle;
timehandle = CreateWaitableTimer(NULL, 0, NULL);
sleeptime.QuadPart = time * -10000;
SetWaitableTimer(timehandle, &sleeptime, 0, NULL, NULL, 0);
while (MsgWaitForMultipleObjects(1, handle, 0, -1, 255) != 0)
{
if (GetInputState() != 0)
{
while (PeekMessageA(&Msg, 0, 0, 0, 1))
{
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
}
}
}
CloseHandle(timehandle);
}
|