Professional Documents
Culture Documents
Metropolia: Exercise 12a. (Function Pointers)
Metropolia: Exercise 12a. (Function Pointers)
Information Technology
Lab. exercise 12
TI00AC30 Algorithms and Datastructures
Page 1
03.04.2014 JV
Option 1.
Create a program, which has an array of times (using your old ADT Time). First enter
times to that array from the keyboard (using your readTime() function) in a random order.
Then order those time entries in a standard way (later time is bigger, e.g. 11:03 is bigger
than 10:54), and print that ordered list of times.
After that (in the same program) order then those times in an array by the minutes field
only (e.g. 10:54 is bigger than 11:03) and print out the same array of times.
Note: use the standard qsort() function for the sorting operation.
Option 2.
Implement an iterator for_all for your linked list implementation (exercises 9 and 10). The
iterator should have a function pointer as a parameter. First create a list of arbitrary length.
Then use the iterator to read new characters to every node. Print then again the whole list
(using iterator) to see that the reading operation has been successfully implemented
Note: in this case we assume that the list already exist.
METROPOLIA
Information Technology
Lab. exercise 12
TI00AC30 Algorithms and Datastructures
stringList;
TcharList charList;
initialize_string_list(&stringList);
initialize_char_list(&charList);
for (i = 0; i < 4 ; i++) //adds characters a,b,c ja d
insert_to_char_list(&charList, 'a'+ i);
insert_to_string_list(&stringList, charList);
initialize_char_list(&charList);
for (i = 0; i < 4 ; i++) //adds characters e,f,g,h
insert_to_char_list(&charList, 'e'+ i);
insert_to_string_list(&stringList, charList);
initialize_char_list(&charList);
for (i = 0; i < 4 ; i++) //adds characters i, j ,k l
insert_to_char_list(&charList, 'i'+ i);
insert_to_string_list(&stringList, charList);
print_string_list(stringList);
}
fflush(stdin); getchar();
Page 2
03.04.2014 JV