- Messages
- 27
- Reaction score
- 0
- Points
- 26
klaruhin mo ng konti. ano input dyan at ano output? ang naiisip ko kasi parang ganito:
sample input:
africa
australia
siquijor
output:
2 continents (africa, australia)
2 islands (siquijor, australia)
linawin mo yung proseso. gagawa ba tayo ng listahan ng islands and continents tapos titingnan natin dun sa listahan na yun kung island or continent ba ang input ng user?
Eto po ung problem
Count the Islands
This Programming exercise requires you to read in a text file, process the contents of the file and output the results.
The file consists of 50 lines of text. Each line consists of 3 sections: First is 3 characters made up of spaces and digits that you can ignore, then 80 characters which are either a space or a + then another 2 characters. The first 3 and last 2 characters are just 1 or 2 digits line numbers padded with spaces. The important part is the 80 characters.
I.e. it will look something like this (the first line <3> etc is not part of the file).
<3><-------------------------------------------80--
--------------------------------------><2>
File starts here:
1 1
27 ++++++++ ++++ +++++++ ++++++++++++ +++ 27
28 ++++++++ ++++ +++++++ ++++++++++++ + ++++ ++++++ 28
This is a map of a game world where each location is either land or sea. Land points are +, sea are spaces. What you have to do is process the 80 x 50 map, determine how many continents there are and output how many continents there are plus a list of those continents, together with the size of each continent. The definition of a continent is one or more connected locations where each location is a +. Connected means that in a 3 x 3 grid around a +, if any of the 8 surrounding locations contains a + then the two are connected.
+
++
+
The 4 locations + are next to each other.
For example your output should look something like this:
There are 5 Continents
Continent 1 has 208 +.
Continent 2 has ...
Note - The actual number of continents may be more or less than 5-that example just shows what output might look like.
naka atach po ung map na bibilangan ng mga +