rand_point.c
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
开发平台:

MultiPlatform

  1. #include <LEDA/window.h>
  2. #include <LEDA/stream.h>
  3. #include <stdlib.h>
  4. main()
  5. {
  6.   window W;
  7.   panel  P;
  8.   string file_name = "points";
  9.   bool file_output = true;
  10.   int N = 10000;
  11.   int max_coord = 1000;
  12.   P.string_item("file",file_name);
  13.   P.bool_item("file output",file_output);
  14.   P.int_item("# points",N);
  15.   P.int_item("max coord",max_coord,0,5000);
  16.   P.open();
  17.   
  18.   file_ostream F(file_name);
  19.   W.init(0,max_coord,0);
  20.   random_source ran(0,max_coord);
  21.   for(int i=0; i<N ; i++)
  22.   { long x,y;
  23.     ran >> x >> y;
  24.     W.draw_pix(x,y);
  25.     if (file_output) F << x << " " << y << "n";
  26.    }
  27.   W.read_mouse();
  28.   return 0;
  29. }
  30.