This preview shows pages 1–3. Sign up to view the full content.
Name _____SOLUTION KEY
________________
Username ___Key
________________
1.
(15pts) Write a function called copy() that copies a onedimensional array into a 2
dimensional array.
Prototype:
void copy(double A[][100], B[],int N, int K)
Where A is the 2dim array and B is the onedim array. K is the number of elements of B and
N indicates the row number of A, which B will be copied to. In other words,
B[0] > A[N][0]
B[1] > A[N][1]
B[2] > A[N][2]
..
..
B[K1] > A[N][K1]
 Your Solution 
void copy(double A[][100], B[],int N, int K){
for ( int i = 0; i < K; i++)
A[N][i] = B[i];
}
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document 2.
(15pts) This question is related to project 6.
You are asked to add a method called
direction(position p) in the position() class.
This method returns a number from 1 to 4. Where 1
represents northeast, 2 northwest, 3 southwest and 4 southeast. It determines in which direction
we need to move to reach the position p.
The prototype is given below.
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.
 Fall '09
 ONAL

Click to edit the document details