-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment07.txt
67 lines (56 loc) · 2.46 KB
/
assignment07.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
A file contains data on a set of employees.
For each employee there is a row of the file, including:
* Last and first name (a single C string, maximum 50 characters,
e.g., Smith_John).
* Personal identification (exactly 16 characters).
* Data of hiring (format dd.mm.yyy, e.g, 30.05.2005).
* Salary (integer value, in euro).
Fields are space-separated.
Employees do not appear in any specific order.
A C program receives 3 parameters on the command line:
* Input file name (the format is the previously defined one).
* A single string, representing a last and first name pair (e.g.,
Clinton_Bill).
* A string made of only + and - characters (e.g., +++---+-+).
The program has to:
* Read the file.
* Store its content in a LIFO-logic list, but with two pointers for
each element one pointing ahead and one pointing behind the element
itself as:
pHead --> ----- --> ----- --> ----- --> ----- -X
|###| |###| |###| |###|
X- ----- <-- ----- <-- ----- <-- -----
* Find in the list the element storing the employee whose name is
passed on the command line as a second parameter.
* Move along the list in the
- right direction for each '+' character
- left direction for each '-' character
in the third string parameter.
For each visited node of the list (including the first one) the
program has to print out (on standard output) all data of the
employee (with the same format this data appears in the original
input file).
If the end of the list is reached (in either side) the program has to
print-out the same element repeatedly.
Example
-------
Let the command line parameters be the following
input.txt Giallo_Antonio ---+
and the file be the following
Rossi_Alberto A1B1C1D1E1F1G1H1 03.12.1998 1845
Giallo_Antonio A2B2C2D2E2F2G2H2 13.11.2007 1140
Verdi_Federica A3B3C3D3E3F3G3H3 25.09.1989 2157
Bianchi_Elena A4B4C4D4E4F4G3H4 15.02.2004 1345
The file has to be stored in the LIFO structure as:
Bianchi -> Verdi -> Giallo -> Rossi
Then, the program has to:
- find Giallo_Antonio in the list and print its data
- move left on Verdi and print its data (first -)
- move left again and print Bianchi (second -)
- do not move and print Bianchi again (third -)
- move right and print Verdi (first +):
Giallo_Antonio A2B2C2D2E2F2G2H2 13.11.2007 1140
Verdi_Federica A3B3C3D3E3F3G3H3 25.09.1989 2157
Bianchi_Elena A4B4C4D4E4F4G3H4 15.02.2004 1345
Bianchi_Elena A4B4C4D4E4F4G3H4 15.02.2004 1345
Verdi_Federica A3B3C3D3E3F3G3H3 25.09.1989 2157