[SOLVED] programming
Im studying for my Computer Science class and need an explanation.
- Write a recursive function that prints all permutations of the characters in a string. Your program is to prompt the user with $>$ (note the blank space after the $>$). The user then enters a string of letters or digits or both, and the program lists the permutations. It then reprompts the user for a new string. It continues doing this until the user enters either a blank line or types an end-of-file (control-D as the first character).
Here is an example. The user types what is in red type; what the computer types is in black type. The % is a shell prompt. The ? means the user typed return or enter (or otherwise entered a newline). Your listing of the permutations need not be in the same order, but it must include all permutations of the input.> 123? 123 231 312 132 213 321 > ab? ab ba > ?
To turn in: Put this program into a file called permute.c; turn it in as directed below.
- (30 points) Throughout the rest of the term, we will build a program to play the game of life, devised by John Conway. It uses a board that is a two-dimensional rectangle divided into small, equal-sized squares. Each square may be populated or unpopulated. The neighbors of a cell are the cells that adjoin it vertically, horizontally, or diagonally.
At each step, the following transformations are applied to all the cells.- If a populated cell adjoins less than 2 other populated cells, or more than 3 populated cells, it becomes unpopulated.
- If a populated cell adjoins 2 or 3 populated cells, it remains populated.
- If an unpopulated cell adjoins exactly 3 populated cells, it becomes populated.
As a first step, you will read the dimensions of the board from the standard input. This will be given as two integers separated by an x (the 24th letter of the alphabet) and possibly white space before and after the numbers and the x. Your output is to be a square composed of -es and |es. If the numbers read are 2 x 8, your square should enclose a 2×8 rectangle. The inside of the rectangle is to be blank.
To turn in: Put this program into a file called life.c; turn it in as directed below. If you want to submit two files, that is, have this in a separate file, call the main one life.c and the other file(s) readrectn.c, where n is a single digit (for example, readrect0.c). Turn it in as described below.