Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: TheQuirk on 28 August 2005, 02:03
-
You have a piece of math paper, 100 by 100 squares. On the paper, there are rectangles. The rectangles do not touch each other.
You have an array of 100 by 100, representing the piece of paper. For every square which is part of a rectangle, the value is 1. For every square which isn't, the value is 0. You have to figure out how many rectangles are drawn on the paper.
For example, the following array would represent a 10x10 piece of paper with two rectangles:
[[0000000000]
[0111100000]
[0111100000]
[0111100000]
[0000000000]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
-
Can rectangles overlap?
[[0000000000]
[0112222000]
[0112222000]
[0002222110]
[0002222110]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
or
[[0000000000]
[0111111000]
[0111111000]
[0002222220]
[0002222220]
[0000000000]
[0000001100]
[0000001100]
[0000001100]
[0000000000]]
-
Nein.
-
So how should the examples I gave be interpreted.
-
It's not an issue; you won't be getting that sort of data. You'll only be getting non-touching, non-overlapping rectangles.
-
COMMUNIST
I mean.
Hello, Glebz0r
-
100 by 100 squares
Feck that, 10x10 will do.
http://illhostit.com/files/3770320186421918/rect.c (http://illhostit.com/files/3770320186421918/rect.c)
piratepenguin@pcdeclan:~/stuff/programming/c/rect$ ./rect
There are 4 rectangles.
Works.