一个类似屏保的程序

来源:互联网 发布:大众软件官方 编辑:程序博客网 时间:2024/04/30 19:36

#include<stdio.h>
struct test
{
 int x,y;
 int xv,yv;
};
delay()
{
 int i,j;
 for(i=0;i<10000;i++)
 for(j=0;j<10000;j++);
}
main()
{
 struct test ts;
 ts.xv=ts.yv=1;
 ts.x=ts.y=10;
 while(!kbhit())
 {
  if(ts.x==0||ts.x==40)
   ts.xv*=-1;
  if(ts.y==0||ts.y==30)
   ts.yv*=-1;
  ts.x+=ts.xv;
  ts.y+=ts.yv;
  gotoxy(ts.x,ts.y);
  printf("%c/b",3);
  delay();
  delay();
  clrscr();
 }
}

原创粉丝点击