CMSC 160 -- Lab 13

Lab 13

Download your lab file

  1. Use wget to download the file at http://cs.longwood.edu/courses/cmsc160/f17/files/lab13.tgz
  2. Uncompress the lab13.tgz file by using tar -xvzf lab13.tgz
  3. Use ls to see that there is a new directory called lab13
  4. Use cd lab13 to change directory to the lab13 directory

The Problems

Here are 15 review problems for the exam. You will need to write eight of the following functions:
  1. reverse
    input:  a string str
    output: the string in reversed order	
    example: "abcde" ==> "edcba"
    
  2. mix
    input:  two strings	
    output: a string
    example: "abcde" "123" ==> "a1b2c3de"	
  3. blend
    input:  two strings	
    output:  every other character with the second string reversed	
    example: "abcde" "123" ==> "a3b2c1de"	
  4. divisors
    input:  an integer	
    output:  the divisors of the integer	
    example: 24 ==> [1,2,3,4,6,8,12,24]	
  5. factors
    input:  an integer	
    output:  the prime factors of the integer	
    example: 24 ==> [2,3]	
  6. removeDups
    input:  a vector of integers	
    output: a vector containing no duplicates	
    example: [1,3,3,2,1,5,0] ==> [1,3,2,5,0]	
  7. loonger
    input:  a string	
    output: a string with every 'o' or 'O' duplicated	
    example: "longwood" ==> "loongwooood"	
  8. noVowels
    input:  a lowercase string	
    output: a string with every vowel removed ("aeiou")	
    example: "longwood" ==> "lngwd"	
  9. sometimesY
    input:  a lowercase string	
    output: a string with every vowel removed ("aeiou" and randomly `y')	
    example: "longwood" ==> "lngwd" (remember rand() returns a random integer)	
  10. gcd
    input:  an int a and an int b 	
    output: the greatest common divisor between two numbers	
    example: 16 64 ==> 16	
  11. Circle
    todo:  write a struct Circle	
    fields: a radius and a center (both x and y)	
  12. circleArea
    input:  a Circle 	
    output: the area of the circle	
  13. countZero
    input:  a two dimensional vector of integers 	
    output: the number of entries in the vector of vectors which contain 0
  14. fileReverse
    input: two strings representing an input file name and an output file name
    output: none 
    todo: open and read the file line by line and 
    write to a file the lines of the text file in reverse... last line first with the characters in each line reversed (last char first...)
  15. shifty
    input:  a string and an int r	
    output: each character in the string should be shifted r positions... characters at the end wrap	
    example: "longwood" 3 ==> "oodlongw"

Handin

Your completed lab is due on Nov. 30th at 6pm. It should be handed in by using the make handin command.