1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <graphics.h>
#include <time.h>
using namespace std;
int main()
{
int g=0,m=0,x1,a,y1,x=0,y=0,b;
srand(time(NULL));
initgraph(&y ,&m,"");
initwindow(800 ,600 , " Dart Random" );
setcolor(15);
circle(x+400, 250 + y, 1);
circle(x+400, 250 + y, 30);
circle(x+400, 250 + y, 45);
circle(x+400, 250 + y, 60);
//y=ax+b
for(int i=0 ;i<=3 ;i++ )
{
int x2 = (rand()%800) + 1;
int y2 = (rand()%600) + 1;
x1=250;
y1=250;
if(x2<346 && x2>454 && y2>310 && y2<36) continue;
a=(y2-y1)/(x2-x1);
b=y1/(a*x1);
circle(x1*b , y1 ,3 );
}
getch();
return 0;
}
|