Cpp2_code_x08 - Name_SOLUTION KEY Username_Key 1(15pts Write a function called copy that copies a one-dimensional array into a 2dimensional array

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Name _____SOLUTION KEY ________________ Username ___Key ________________ 1. (15pts) Write a function called copy() that copies a one-dimensional array into a 2- dimensional array. Prototype: void copy(double A[][100], B[],int N, int K) Where A is the 2-dim array and B is the one-dim 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[K-1] -> A[N][K-1] --------------------------------------------------------- Your Solution ------------------------------------------------------- void copy(double A[][100], B[],int N, int K){ for ( int i = 0; i < K; i++) A[N][i] = B[i]; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
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.
Background image of page 2
Image of page 3
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.

Page1 / 4

Cpp2_code_x08 - Name_SOLUTION KEY Username_Key 1(15pts Write a function called copy that copies a one-dimensional array into a 2dimensional array

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online