1. Determining the kind of triangle
You are given the x and y coordinates of three points on the plane. These three points may or may not form a triangle. The problem is to determine as many of the following properties as are applicable to the triangle formed:
no triangle acute right obtuse isosceles equilateral scalene
"No triangle" is formed if the points are collinear. An "acute" triangle is formed if all the angles are acute angles. A "right" triangle is formed if one of the angles is a right angle. An "obtuse" triangle is formed if one of the angles is an obtuse angle. An "isosceles" triangle is formed if two of the sides are equal. An "equilateral" triangle is formed of all three sides are equal. A "scalene" triangle is formed if all three sides are unequal.
The input to the program conmsists of the three points. For example:
0.8 1.2 5.1 4.3 -3.7 6.5
The output of your program consists of one or more lines of properties of the triangle formed, one property per line. Print out all properties that apply to the given triangle.
2. Computing the Perimeter of Triangles
You are given the x and y coordinates of n points on the plane. Here n is between four and ten. The problem is to find from among these n points three points which form a triangle of maximum perimeter, among all such possible triangles.
Example input data:
5 // the value of n 1.2 1.1 // coordinates of point 1 3.1 -2.3 // coordinates of point 2 2.0 5.4 // coordinates of point 3 -2.2 1.7 // coordinates of point 4 -1.2 -4.8 // coordinates of point 5
The output of your program is the value of the maximum perimeter.
3. Counting permutations with a given run length
Given the set S = { 1, 2, 3, ... , n } of n integers, where n is between four and eight. A permutation of S is any ordered arrangement of its elements. The following are some permutations of set S where n = 4:
1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 ... 4 3 2 1
The run length of a permutation is the maximum number of elements in the permutation that are in increasing order. For example, the permutation (4 3 1 2) has run length of two, since the subsequence (1 2) is in increasing order. The permutation (3 1 2 4) has run length 3 since (1 2 4) is in increasing order.
The problem is to determine how many of the permutations of the set S has run length one, how many has run length two, how many has run length three, etc.
The only input is the value of n.
The output of your program consists of n lines:
1 count1 2 count2 3 count3 ... n countn
Here countk is the number of permutations with run length k.
4. Computing the convex hull.
You are given the x and y coordinates of n points on the plane. Here n is between four and fifty. The problem is to find the polygon of minimum perimeter so that all the given points are either inside or on the polygon.
The input to the program has the following form
n // the number of points (integer) x1 y1 // coordinates of point1 (float float) x2 y2 // coordiantes of point2 (float float) ... xn yn // coordinates of pointn (float float)
The output of your program is the perimeter of the enclosing polygon.
5. Determining relationship of points to a line.
You are given the x and y coordinates of n points on the plane. The problem is to determine a (straight) line that passes through the most number of points, and to determine how many points are above this line, on this line, and below this line.
The input to the program has the following form:
n // the number of points (integer) x1 y1 // coordinates of point1 (float float) x2 y2 // coordiantes of point2 (float float) ... xn yn // coordinates of pointn (float float)
The output of your program has the form:
m b // slope and y intercept of required line a // number of points above the line n // number of points on the line b // number of points below the line