Program 1 (Worth 70 points) keeps adding on random values

advertisement
Program 1 (Worth 70 points)
Program 2 (worth 80 points)
Consider a counter that starts at 1 and
keeps adding on random values
between 0-10 to itself until we get to
200. Use a recursive solution please,
no loops allowed.
Create a recursive solution to output all
the even numbered values in an array.
Do not use any loops.
Program 3 (Worth 90 points)
Program 4 (worth 95 or 100 points)
Generate the following output using
recursion
Project Travel 2D array:
0
012
0123
01234
012345
0123456
01234567
012345678
0123456789
Create an integer array of size 20 and
give it random values between 0-100 for
your test. You may use a loop to
initialize your array.
We want to get from one point of a 2D
array to another. We can only travel
north, south, east, or west. No
diagonals.
We will generate random starting
locations but finish location will be any
of the four corners.
Whenever you travel to a cell, you pick
up the value in that cell. Every step you
take, needs to get you closer to your
goal, meaning don’t take unnecessary
steps.
Write a recursive solution that will get
you from any point of a 2D array to one
of the corners using this method. Once
your travel is complete, display the
total sum that you picked up.
Generate a 20 x 20 2D array with
random values between 0-100 for your
test. You may use a double loop to
initialize your array.
For your output, generate a random
starting location, display this location.
Now get to any corner. Display your
travel and the weight picked up along
the way. At the end, display your total
weight.
Output Example:
Starting: (5,5)
(4,5)
(3,5)
(2,5)
(1,5)
(0,5)
(0,4)
(0,3)
(0,2)
(0,1)
(0,0)
weight:
weight:
weight:
weight:
weight:
weight:
weight:
weight:
weight:
weight:
67
17
5
78
14
36
25
74
98
44
Total Weight: 458
For 95, you get to a fixed corner no
matter where you start.
For 100, you get to your closest corner.
Download