[A+DS] >>>prac 2>>>

## CSE2304, Prac' 1, week 2, 8-12 March 1999

### also CSC2040, CSE2324, CSE3324, CSC2240 and CSC3240

 The course CSE2391/CSE3391 Unix Tools is on advanced uses of Unix, but it does contain some pointers to introductory material: [web].

Everyone has a lab' in week 2. The purpose is to become familiar with the lab' equipment and the Linux / Unix operating system.

From Lab #2, weeks 3 and 4, onwards, groups A and B alternate.

1. Create a subdirectory for work related to this course, and a subdirectory within that for this prac'.
2. Produce a C program to solve the following simple(?) problem (you will need to prepare the algorithm before the lab'):
1. Read in a sequence of integers, n1, n2, ..., nm, from standard input, the numbers being separated by white space (spaces or newlines) and terminated by the end-of-file. You can assume that they will fit in a large array that you might allocate.
2. Find the maximum sum interval, <i,j>, s.t. SUMk=i..j nk is as large as possible.
3. Print i, j and the sum of the interval.
4. e.g.If the input is: `3 -4 -2 2 2 -3 4 -5 2 1`, then the interval is <4,7> and its sum is 5.
3. Produce a set of important data test-cases that test the program as thoroughly is possible.
4. Investigate and/or describe how the running-time of the program varies with `m', which might be very large, or with other properties of the data or the output.

There are no marks for this exercise, but attendance is compulsory, and you will almost certainly be in difficulties in following weeks if you do not complete this lab'. The demonstrators will give you feedback on what they will be looking for in future, marked exercises.

### Useful commands:

• `man blah` :print the manual entry on command `blah', very useful!

• `ls ` :list the contents of the current working directory
• `ls -l ` :list in long format.
• `ls -la ` :list, in long format, all files, including `.foo' etc..
• `ls dirName ` :list contents of directory `dirName'.
• `mkdir dirName ` :make a sub-directory called `dirName'.
• `rmdir dirName ` :remove a directory called `dirName' (if empty).
• `cd dirName ` :change to directory `dirName'
• `cd ` :to your home directory, or `cd ~`
• `cd .. ` :to the directory up one level.

• `cat fileName ` :print contents of file `fileName'.
• `vi fileName ` :edit a file called `fileName' using `vi'. NB. You have to make your own backup copy first if you want one.
• `cp f1 f2 ` :copy file `f1' to `f2', creating f2 if necessary.
• `mv oldName newName ` :move or rename a file called `oldName' to a destination `newName'.
• `rm fileName ` :remove file called `fileName', dangerous.

• `gcc ` :the gnu C compiler. Compiled programs have the suffix ``.out`' by default.
• `make ` :organise the compilation of multi-file programs.

• `logout ` :bye bye.

• `awk ` :pattern scanning and processing.
• `grep ` :search for regular expression in file(s).
• `sed ` :stream editor, useful in shell scripts.