next up previous


CSE 2320 Section 501/571 Fall 1999

Program 1

Due: September 21, 1999, 5:30pm (September 22, 1999, 5:00pm for -10%)

Implement the recursive, divide-and-conquer version of LOGICALAND from Homework 1, problem 5. You may write your code in C or C++, but cannot use global variables. In addition to correctness, programming style is also important, so please write modular, well-documented code.

1.
Read and follow the Coding Standards document on the course web page (although portions of section 2 are not applicable to the programs in this course, as I want you to keep all your code in one file).

2.
Implement the recursive, divide-and-conquer function LOGICALAND(A,B,C,p,r) that stores the logical-and of the binary arrays A[p..r] and B[p..r] into binary array C[p..r].

3.
The main part of your program will read in data from a file whose name is given as the first argument to your executable. The first line of the input file contains the number of triples (1-999) in the rest of the file. Each subsequent three-line triple begins with the number of array elements (1-999), followed by the elements of A (0 or 1) on the next line, and followed by the elements of B (0 or 1) on the next line. Your main program should process each triple one at a time by reading in the Aand B arrays, calling LOGICALAND, and then printing arrays A, Band C. For example, if your compiled program is in a.out, and you want to run it on the sample input file pgm1in that is in the directory /public/cse/2320-501 on omega, you should do the following:

omega> a.out /public/cse/2320-501/pgm1in

The output of your program should be sent to standard output. The output format for the pgm1in example is on pgm1out. This format should be followed as close as possible.

4.
Be sure to properly document your source code. If you are unsure about the level of comments, please ask the GTA, who will be grading your programs. Also, in the comment at the top of your source code, you must include the program number, your full name, ID number, login, class (2320), and a line indicating how to compile your program (e.g., compile using: cc or compile using: gcc -lm).

5.
After ensuring that your program compiles and executes correctly on the omega machine, run the program /public/cse/2320-501/handin1 to electronically hand in your source file. All source code must be in one file (i.e., no separate .h and .c files). The handin program will prompt you for the file name containing your source code and will output the date and time when your program was handed in. Be sure you are in the directory containing your source file when you run the handin program. Note: You may run the handin program as many times as you like, but only the most recently handed in file will be retained. Do not turn in a printout of your source code in class.


next up previous