Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. struct punct {
  6. int x,y;
  7. };
  8.  
  9. int X, Y;
  10. punct v[20];
  11. int n;
  12. int S;
  13. int xs, ys, xd, yd;
  14.  
  15. void taiere(int x1, int y1, int x2, int y2) {
  16. //x1,y1; x2,y2 - coordonatele coltului stanga-jos,dreapta-sus;
  17. int g=0, poz;
  18. for(int i=1; i<=n && !g; i++) //ma opresc cand dau peste o perforatie in interiorul suprafetei
  19. if(v[i].x>x1 && v[i].x<x2 && v[i].y>y1 && v[i].y<y2) {
  20. g=1;
  21. poz=i;
  22. }
  23.  
  24. if (g==1) {
  25. taiere(x1, v[poz].y, x2, y2); // deasupra
  26. taiere(x1, y1, x2, v[poz].y); // dedesubt
  27. taiere(x1, y1, v[poz].x, y2); // stanga
  28. taiere(v[poz].x, y1, x2, y2); // dreapta
  29. }
  30. else if ((x2-x1)*(y2-y1)>S) {
  31. xs=x1;
  32. ys=y1;
  33. xd=x2;
  34. yd=y2;
  35. S=(x2-x1)*(y2-y1);
  36. }
  37. }
  38. int main()
  39. {
  40. ifstream f("placa.in");
  41. f>>n;
  42. for(int i=1; i<=n; i++)
  43. f>>v[i].x>>v[i].y;
  44. f>>X>>Y;
  45. taiere(0, 0, X, Y);
  46. cout<<endl<<"Cea mai mare suprafata neperforata are coordonatele ("<<xs<<","<<ys<<");("<<xd<<","<<yd<<")"<<endl;
  47. cout<<"suprafata= "<<S;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement