Advertisement
aimon1337

gauri

Jan 28th, 2020
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. using namespace std;
  5. //ifstream f("gauri.txt");
  6. int n,l,h,xg,yg,lg,hg;
  7. int ox[20],oy[20];
  8. //void smax(int x0,int y0,int lung,int inalt);
  9. void smax(int x,int y,int lung,int inalt)
  10. {   bool egaura=false;
  11.     int i=1;
  12.     while(i<=n&&!egaura)
  13.         if((ox[i]>x)&&(ox[i]<(x+lung))&&(oy[i]>y)&&(oy[i]<(y+inalt)))
  14.             egaura=true;
  15.         else
  16.             i++;
  17.     if(egaura)
  18.     {
  19.             smax(x,y,ox[i]-x,inalt);
  20.             smax(ox[i],y,x+lung-ox[i],inalt);
  21.             smax(x,y,lung,oy[i]-y);
  22.             smax(x,oy[i],l,y+inalt-oy[i]);
  23.     }
  24.     else
  25.         if(lung*inalt>lg*hg)
  26.             {
  27.                 xg=x;
  28.                 yg=y;
  29.                 lg=lung;
  30.                 hg=inalt;
  31.             }
  32.  
  33. }
  34. int main()
  35. {
  36.     cin>>l>>h>>n;
  37.     for(int i=1;i<=n;i++)
  38.         cin>>ox[i]>>oy[i];
  39.     xg=0;
  40.     yg=0;
  41.     lg=0;
  42.     hg=0;
  43.     smax(0,0,l,h);
  44.     cout<<endl<<"coordonate x="<<xg<<" y="<<yg<<" L="<<lg<<" H="<<hg;
  45.     getch();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement