2. Use the struct timespec structure and the timespec_get function declared in time.h (C standard, paragraph 7.27.2.5, p.391/409) to benchmark the time taken by some code of your choice (be sure to run it many times).
3. A real number 0 < x < 1 can be successively approximated in a
continued
fraction with 1/a1, 1/(a1+1/a2), 1/(a1+1/(a2+1/a3)), ...
where a1, a2, a3, ... are natural numbers. In the initial
approximation, a1 is ⌊1/x⌋, and one continues using the
same rule for the fractional part of the denominator approximated with
a1, etc. One obtains a sequence of rational numbers p1/q1,
p2/q2, ... that approximate x increasingly well, alternating from above
and below.
Define a structure that represents a rational number and compute recursively
the nth rational approximation of a fractional number x
using a continued fraction.
4. A .csv file contains the grade situation for a class of
students. Each line contains fields separated by commas. The first
field is the student name, followed by up to 10 fields with real-numbered
grades or other characters; any remainder of the line is ignored.
Read the file using an appropriate data structure; you may assume there
are at most 200 students. Compute averages for the students that have 10
passing grades. Sort students in decreasing order of their grade averages;
break ties in alphabetical order. Print the sorted list with grade averages.
5. A propositional formula in conjunctive normal form is represented as a conjunction of clauses which are disjunctions of literals, as follows:
(and (or lit11 lit12 ...) (or lit21 lit22 ...) ... (or litn1 litn2 ...) )with arbitrary many literals per clause and arbitrary many clauses; the amount and type of whitespace does not matter. Literals are represented by nonzero integers: a positive integer n denotes proposition pn, a negative integer -n denotes its negation ¬pn.
Marius Minea Last modified: Tue Dec 3 14:30:00 EET 2013