Advertisement
Farjana_akter

Untitled

Mar 10th, 2019
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool spot[500][500]={false};
  4. int main()
  5. {
  6. int w,h,n;
  7. while(1)
  8. {
  9. cin>>w>>h>>n;
  10. if(w==0)
  11. break;
  12. int x1,x2,y1,y2,i,j,k,count=0;
  13. while(n--){
  14. cin>>x1>>y1>>x2>>y2;
  15. if(x1>x2)
  16. swap(x1,x2);
  17. if(y1>y2)
  18. swap(y1,y2);
  19. for(i=x1-1;i<x2;i++)
  20. {
  21. for(j=y1-1;j<y2;j++)
  22.  
  23. {
  24. spot[i][j]=true;
  25. }
  26. }
  27. }
  28. for(i=0;i<w;i++)
  29. {
  30. for(j=0;j<h;j++)
  31. {
  32. if(spot[i][j]==false)
  33. count++;
  34. else
  35. spot[i][j]=false;
  36. }
  37. }
  38.  
  39. if(count==0)
  40. cout<<"There is no empty spots."<<endl;
  41. else if(count==1)
  42. cout<<"There is one empty spot."<<endl;
  43. else
  44. cout<<"There are "<<count<<" empty spots."<<endl;
  45. }
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement