Advertisement
gabrielcabezas

Untitled

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