[Note: this webpage last modified Thursday, 14-Nov-2013 15:45:40 EST]
Most of my courses (including this one) include programming assignments in C which are turned in on the CS server. For information on setting up the software and handing in assignments, see software and HW.
Stack HW. Finish the stack.c program. CANCELED - will not be graded, let me know if you want me to look at your program.
Word frequency the slow way. Finish the outline, make the output the same as the correct example. Name your file wordfrequency.c or wordfrequency.cpp. There is a correct working example in ~jkinne/public_html-/cs559/code/. Due Thursday by midnight, worth 20 points.
You can test your program on shakespeare.txt, which is in
the in-class code. When you run it, make sure to redirect the
output to a file, like
./wordfrequency shakespeare.txt > ~/output.txt
Due Sept 26.
int strncmp559(char *s1, char *s2, int n);
We'll do our own strcmp. Normally, it just goes by the order in the ASCII table. Here's our ordering rules... (1) lower-case and upper-case are the same. (2) first vowels, then digits, then consonants, then punctuation, then white space.
Testing that your program is correct... First, copy the files strncmp559Jeff.o and strncmp559test.o into the directory where you have your .c or .cpp file. Make sure your .c or .cpp file has the strncmp559 function defined as above, and DO NOT put a main function in your file. There is a main function in the strncmp559test.o file that will test your code. With the .o files and your .c or .cpp file in the same directory, compile them like gcc strncmp559Jeff.o strncmp559test.o strncmp559.c -o outputName
Or similarly with g++. Then run the outputName file, and it will test your strncmp559 function and tell you if it failed any test cases.
Make sure to name your file strncmp559.c or strncmp559.cpp
Due Oct 1.
long int addPerfectPowersEasy(int n);
long int addPerfectPowersHard(int n);
long int addPerfectPowersHardest(int n);
Supposed to add up all the perfect powers that are less than or equal to n. That includes perfect squares, cubes, etc. The "Easy" version adds duplicates multiple times. The "Hard" version includes duplicates only once. If n is negative, return 0. Except in the "Hardest" function, that should add up perfect odd powers if n is negative. You can assume that abs(n) will be at most 225. You should also not count 1 as a perfect power in the summation. So addPerfectPowersEasy(1) should be 0.
To test whether your program is correct... Call your filename with the functions
addPerfect.c, and DO NOT have a main function in the file.
Copy the files addPerfectJeff.o and addPerfectTest.o from the
in-class code directory into your account with your file. Compile and run the tests
with
gcc addPerfectJeff.o addPerfectTest.o addPerfect.c -o outputName
./outputName
Or similarly with g++.
Make sure to name your file addPerfect.c or addPerfect.cpp, and include each of the three functions in that file.
In your cs458xx/handin/ directory, put a text filed called ideas.txt with (1) idea for opensource (have a link to it, and brief description of what it does), (2) idea for "build it ourselves". Due Monday Oct 14 11:59pm.
Due Oct 21 by 11:59pm. Finish the lookup, remove, top in the deck class, so they work. And operator> in the card class. Note: no late credit. First get testDeck working, then playWar.
Due Oct 29 by 11:59pm. Program encrypt559.c. Note - do it in C rather than C++. One of your courses in the spring will be in C, so you need the practice at C.
Program should take two command-line arguments. The first specifies the encryption method to use. The second specifies the passcode to use with that algorithm. The program reads from standard input until EOF is detected (until (ch = fgetc(stdin)) == EOF). Everything read from standard input is encrypted and written to standard output.
Encryption algorithms you should implement:
none - if none is specified, then just write out the characters
unchanged.
caesar - if specified, then use the caesar cipher, with the passcode
being an integer between 0 and 25 specifying how much to shift
each letter. Note: do not modify non-alpha characters, pass those
through unchanged.
vigenere - if specified, then do a Vigenere cipher, with the passcode being characters
that specify the password. Like the caesar cipher, leave non-alpha
characters alone - pass them through unchanged.
Due Oct 29, by 11:59pm. Large integer class. Define the class like... ASSIGNMENT CANCELED.
asciiCount.c or asciiCount.cpp. Take our wordcount.c and modify it so it also prints out the following counts: number of spaces, number of end-of-sentence marks (. ! ?), number of in-the-middle-of-sentence marks (, ; : -). Still have it print out the lines, words, characters, then print the new ones on a second line. There is a correct working program in the in-class code.
Stage 1. Call your program shape1.c or shape1.cpp. It takes no input,
and in sequence draws the following:
horizontal line out of _ that is 25 _'s wide,
vertical line out of | that is 10 |'s tall,
rectangle out of | _ - that is 25x10.
Notes: you must use loops. There is a correct working program in the
in-class code.
Stage 2. Call your program shape2.c or shape2.cpp. It takes no input,
and in sequence draws the following:
horizontal lines of width 1 up to 25,
rectangles of dimension 2h X h for h = 2 up to 10.
And put newlines in between each shape. There is a correct working
program in the in-class code.
Stage 3. Call it shape3.c or shape3.cpp. It takes input! The program should keep reading from standard input as long as it can (until the end of input is reached). In c++, you'd have a while (cin >> s) loop, where s is a string. The legal "commands" given in the input are: hline, vline, rect. The hline and vline commands will be followed by a single integer specifying the length of the line. The rect command is followed by 2 integers to specify the width and height. If // is read, then everything from there to the end of the line in the input is ignored. A sample input file is given in shape3.input in the in-class code. There is a correct working program in the in-class code that is called shape3. You can test it by running ./shape3 < shape3.input
Test topics: 70% basic C programming, and 30% basic C++ programming. For both - you should be proficient at: loops, functions, arithmetic, user input/output, file input/output, arrays, structures, dynamic memory (malloc/free, new/delete). For C++, need to be able to make basic class, including constructors, destructors, overloaded operators.
Test on Nov 21. Exam on the final exam day, same exact topics. If you do better on final, then that's what counts.
Example programs: word count, primes, strcmp, strstr, hangman, convert file to uppercase, ...
C++ example programs: classes for a bank/account, classes for a binary search tree, classes for employees, given a class already defined fill in something (overloaded operator), ...
C++ reference: tutorial.
C reference: The C Programming Language.
Test questions will be...: On paper...