/*************************************************** * sierpin.cc: Creates Sierpinsky Carpet * * written by: Paul M Eugenio * Department of Physics * Florida State University ****************************************************/ #include #include using namespace std; int main() { double r; // random number double x =0.0; // x coordinate double y =0; // y coordinate double max = 10e3; // max number of points // // simple structure to contain // the triangle vertices coordinates // struct vert_s { double x; double y; }V[3]; // simple equilaterial triangle V[0].x=0; V[0].y=0; V[1].x=1; V[1].y=0; V[2].x=0.5; V[2].y=1; //seed48() int n; for (int i=0; i 1/3 && r <= 2/3 // n=2 if r > 2/3 && r < 1 // print point to the standard output cout << x << " " << y << endl; } }