Assignment 1: Cs 2255 - Computer Science Ii
Assignment 1: Cs 2255 - Computer Science Ii
Plantation
There are N trees in a plantation. Each tree is assigned an information card which notes the
following information: location (x, y), type (coffee or tea).
The plantation manager wants to construct a fence around the plantation. For minimum cost, the
fence length needs to be as short as possible.
The manager also wants to build a watering system based on tubes to let water runs from the
pump to each tree. The location of the pump needs to be considered to minimize the total length
of the used tubes.
Guidance:
a) First, declare necessary C structs to represent the plantation.
}; }; };
}
// Count tea trees.
int countTeaTrees(…….….…………………...)
{
} }
1
c) Write C functions to calculate the shortest fence length need to be built.
}
// Use functions in right column.
// Calculate perimeter of rectangular fence. // Find lower right point.
float calcFenceLength(...……..……………) Point findLowerRight(Plantation p)
{ {
} }
d) Let the program calculate the minimum total length of used tubes.
} }
2
e) Let the program input and output through file.