高手啊。你在那里?
下面是随机输出A---Z之间地7个字母,当没有输入的情况下,字母重复出又消失,如果有输入,当输入这个字母屏幕上也有这个字母,这个字母消失。怎么输入了,这个字母不消失,
/* HELLO.C -- Hello, world */
#include <stdio.h>
#include <graphics.h>
#include <time.h>
#include <stdlib.h>
#include<dos.h>
#include<conio.h>
void init(void);
void draw(void);
void strat();
void time_();
int key;
void main()
{
init();
draw();
strat();
getch();
}
void init (void)
{
int gm=0,god=0;
initgraph(&gm,&god,"c;\\tc");
}
void draw()
{
int i;
setcolor(11);
for(i=0;i<=635;i=i+10)
rectangle(i,0,i+10,10);
for(i=0;i<635;i=i+10)
rectangle(i,469,i+10,479);
for(i=0;i<=479;i=i+10)
rectangle(0,i,10,i+10);
for(i=0;i<=469;i=i+10)
rectangle(625,i,635,i+10);
}
void strat(void)
{
int m,n,t,key;
time_t p;
int x[10],y[10],a[10];
srand((unsigned) time(&p));
for(t=0;t<8;t++)
{
x[t]=rand()%80;
y[t]=rand()%25;
a[t]=rand()%26+65;
time_();
gotoxy(x[t],y[t]);
setcolor(4);
printf("%c ",a[t]);
}
while(1)
{
while( !kbhit())
{
srand((unsigned)time(&p));
t=rand()%8;
setcolor(0);
rectangle (x[t],y[t],x[t]+10,y[t]+10);
srand((unsigned) time(&p));
x[t]=rand()%350+100;
y[t]=rand()%540+100;
srand((unsigned)time(&p));
a[t]=rand()%36+35;
time_();
gotoxy(x[t],y[t]);
printf("%c",a[t]);
time_();
}
key=bioskey(0);
for(t=0;t<8;t++)
{
if(key==a[t])
{setcolor(0);
rectangle (x[t],y[t],x[t]+10,y[t]+10);
srand((unsigned) time(&p));
x[t]=rand()%350+100;
y[t]=rand()%540+100;
srand((unsigned)time(&p));
a[t]=rand()%36+35;
time_();
gotoxy(x[t],y[t]);
printf("%c",a[t]);
}
time_();
}
}
}
void time_()
{
int a;
for(a=0;a<10;a++)
delay (100000);
}