"Warmup" Programming Assignments
See
Program 10189 or see below:
Implement in a language of your choice.
In order to use the online judge, use Java, C, C++, or Pascal.
Register for the online judge
Your program needs a comment line such as:
/* @JUDGE_ID: 1000AA 100 C "Dynamic Programming" */
The argument after the @JUDGE_ID: is your user ID (1000AA for example), followed by the problem number (100 in the example),
then by the language used.
FOR FULL CREDIT you must submit your programs and have them "Accepted" by the online judge
Here are the warmup problems:
- The 3n + 1 problem (program number for judge submission: 100)
(Sample starter in C, and also
Java version)
(Also, see these shell versions if you need more help:
C and
Java version)
- Minesweeper (program number for judge submission: 10189)
(Sample starter in C
(dynamic allocation) and
starter in C (static allocation)
Also see these shell versions if you need more help:
C and
Java version
- The goal of the game is to find where all the mines are located within a M x N field.
- The game shows a number in a square which tells you how many mines there are
adjacent to that square. Each square has at most eight adjacent squares. The
4 x 4 field on the left contains two mines, each represented by a "*" character.
If we represent the same field by the hint numbers described above, we end up
with the field on the right.
* . . . * 1 0 0
. . . . 2 2 1 0
. * . . 1 * 1 0
. . . . 1 1 1 0
- Input: The input will consist of an arbitrary number of fields. The first
line of each field contains two integers n and m (both are
greater than 0 and less than or equal to 100) which stand for the number of rows
and columns of the field. Each of the next n lines contains exactly m
characters representing the field.
- Safe squares are denoted by "." and mine squares by "*". The first field line where
n = m = 0 represents the end of the input and should not be processed.
- Output: For each field, print the message Field #x: on the line alone,
where x stands for the number of the field starting from 1. The next n
lines should contain the field with the "." characters replaced by the number of mines
adjacent to that square. There must be an empty line between field outputs.
Sample input Sample output
4 4 Field #1
* . . . * 1 0 0
. . . . 2 2 1 0
. * . . 1 * 1 0
. . . . 1 1 1 0
3 5 Field #2
* * . . . * * 1 0 0
. . . . . 3 3 2 0 0
. * . . . 1 * 1 0 0
0 0
In your ouput and input, you don't need to put spaces between the characters.