Hello everyone,
I'm working on an assignment where I have to read records from a file and load them in parallel arrays. the student names are in a 1D array and the three marks for that student are in a 2D array. I need to load these and Im not sure how to use 2D arrays in pseudocode plz help,
thanks
Loading
VulpesPosted Aug 17, 2011, 11:49 AM
READ all lines from students.txt into a 'lines' array
STORE the number of elements in 'lines' in 'len'
CREATE an array 'names' of length 'len'
CREATE a two dimensional array 'marks' whose dimensions have lengths 'len' and 3
FOR i = 0 TO len - 1
TRIM lines[i] of any leading or trailing space
SPLIT lines[i] into 4 individual items using a comma as separator
STORE the items in an 'items' array
names[i] = items[0]
FOR j = 1 TO 4
CONVERT items[j] to an integer 'k'
marks[i, j-1] = k
NEXT j
NEXT i
I've expressed the 2 dimensional array using the marks[i,j] syntax rather than marks[i][j].
This is because the array is rectangular rather than jagged and C# distinguishes between the two using the above syntax.
Sam HobbsPosted Aug 18, 2011, 12:08 AM
If someone such as a professor says that pseudocode is supposed to be in a specified format, then you must get that format from that professor.
Avuya MxoliPosted Aug 17, 2011, 9:52 AM
VulpesPosted Aug 16, 2011, 2:47 PM