C++ !
Create a Stash class specifically for storing Rect objects and call it RectStash. Add a default constructor and a destructor to correctly initialize your RectStash class. Then write a program that will read several lines as input. Each line will contain 4 floats defining a 2D rectangle in the Rect format described above. Read the rectangles adding them to a RectStash object. Stop reading rectangles when your program loads 4 negative float values. After this point you will start reading a series of 2D points, and for each 2D point you will print the classification of each point in respect to all previously read rectangles. The classification should print \"in\" or \"out\" according to its result. Stop your program when you read vector (-99,-99).
Everything should be contained in one file. You may not assume the existance of any header files in your working directory.
Sample Input:
-5 -5 2.5 2.5
5 8 2 2
-1 -1 -1 -1
0 0
-4 -6
6 9
-99 -99
result:
out out
in out
out out
# include
# include # include # include void show_screen( ); void Rectangle(constint,constint,constint,constint); void Line(constint,constint,constint,constint); int main( ) { int driver=VGA; int mode=VGAHI; int x_1=0; int y_1=0; int x_2=0; int y_2=0; do { show_screen( ); gotoxy(8,10); cout<<\"Coordinates of Left Point (x1,y1) :\"; gotoxy(8,11); cout<<\"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\"; gotoxy(12,13); cout<<\"Enter the value of x1 = \"; cin>>x_1; gotoxy(12,14); cout<<\"Enter the value of y1 = \"; cin>>y_1; gotoxy(8,18); cout<<\"Coordinates of Right Point (x2,y2) :\"; gotoxy(8,19); cout<<\"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ\"; gotoxy(12,21); cout<<\"Enter the value of x2 = \"; cin>>x_2; gotoxy(12,22); cout<<\"Enter the value of y2 = \"; cin>>y_2; initgraph(&driver,&mode,\"..\\\\Bgi\"); setcolor(15); Rectangle(x_1,y_1,x_2,y_2); setcolor(15); outtextxy(110,460,\"Press to continue or any other key to exit.\"); int key=int(getch( )); if(key!=13) break; } while(1); return 0; } /*************************************************************************///--------------------------- Rectangle( ) ----------------------------///*************************************************************************/void Rectangle(constint x_1,constint y_1,constint x_2,constint y_2) { Line(x_1,y_1,x_2,y_1); Line(x_2,y_1,x_2,y_2); Line(x_2,y_2,x_1,y_2); Line(x_1,y_2,x_1,y_1); } /*************************************************************************///-------------------------------- Line( ) ----------------------------///*************************************************************************/void Line(constint x_1,constint y_1,constint x_2,constint y_2) { int color=getcolor( ); int x1=x_1; int y1=y_1; int x2=x_2; int y2=y_2; if(x_1>x_2) { x1=x_2; y1=y_2; x2=x_1; y2=y_1; } int dx=abs(x2-x1); int dy=abs(y2-y1); int inc_dec=((y2>=y1)?1:-1); if(dx>dy) { int two_dy=(2*dy); int two_dy_dx=(2*(dy-dx)); int p=((2*dy)-dx); int x=x1; int y=y1; putpixel(x,y,color); while(x