Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct punct {
- int x,y;
- };
- int X, Y;
- punct v[20];
- int n;
- int S;
- int xs, ys, xd, yd;
- void taiere(int x1, int y1, int x2, int y2) {
- //x1,y1; x2,y2 - coordonatele coltului stanga-jos,dreapta-sus;
- int g=0, poz;
- for(int i=1; i<=n && !g; i++) //ma opresc cand dau peste o perforatie in interiorul suprafetei
- if(v[i].x>x1 && v[i].x<x2 && v[i].y>y1 && v[i].y<y2) {
- g=1;
- poz=i;
- }
- if (g==1) {
- taiere(x1, v[poz].y, x2, y2); // deasupra
- taiere(x1, y1, x2, v[poz].y); // dedesubt
- taiere(x1, y1, v[poz].x, y2); // stanga
- taiere(v[poz].x, y1, x2, y2); // dreapta
- }
- else if ((x2-x1)*(y2-y1)>S) {
- xs=x1;
- ys=y1;
- xd=x2;
- yd=y2;
- S=(x2-x1)*(y2-y1);
- }
- }
- int main()
- {
- ifstream f("placa.in");
- f>>n;
- for(int i=1; i<=n; i++)
- f>>v[i].x>>v[i].y;
- f>>X>>Y;
- taiere(0, 0, X, Y);
- cout<<endl<<"Cea mai mare suprafata neperforata are coordonatele ("<<xs<<","<<ys<<");("<<xd<<","<<yd<<")"<<endl;
- cout<<"suprafata= "<<S;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement