注册 登录
编程论坛 C图形专区

模拟磁盘寻道,图形显示问题

LC→雷 发布于 2010-05-12 22:50, 758 次点击
我们的操作系统的作业,模拟磁盘寻道,在显示器上画出一系列同心圆代表磁盘,用一个点代表磁头,用随机函数生成磁盘访问序列。但是我的图形重绘的时候不显示同心圆,麻烦大家帮我看下,谢谢了。
只有本站会员才能查看附件,请 登录
1 回复
#2
LC→雷2010-05-15 10:25
#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include<conio.h>

void main()
{

    /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int i=0,j,k;
   int radius=6;
   int array[50];

   /* initialize graphics, local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)
   /* an error occurred */
   {
      printf("Graphics error: %s\n",
      grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   /* terminate with an error code */
   }
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   setcolor(RED);

   /* Create random numbers */

  srand((unsigned)time(NULL));
  printf("Create random numbers!\n");
  for(j=0;j<=15;j++)
  {
  array[j]=rand()%41;
  printf("%d\n",array[j]);
  delay(90000);

  }

   for(k=0;k<=15;k++)
   {
      cleardevice();

       for(;i<=40;i++)
     {

      circle(midx,midy,radius);
      radius=radius+6;

      }

     putpixel(midx+(array[k]+1)*6, midy, GREEN);

     delay(900000);


   }









  /* clean up */
  getch();
  closegraph();
}


这是程序的源代码,圆显示完了就没有了啊/我想让他在寻道时显示出来圆啊
1