Quiz2Answers

Quiz2Answers - public class Quiz2Answers cfw_ /* * /...

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

View Full Document Right Arrow Icon
public class Quiz2Answers { //********************************************************************************* ******* // Variations on the first question. //********************************************************************************* ******* // first question for Thurs 8:00AM, Fri 11:00AM, CS1111 public static int[] twoSmallest (int[] A){ int ret [] = {Integer.MAX_VALUE, Integer.MAX_VALUE}; for(int i = 0; i < A.length; i++){ if(A[i] < ret[0]){ ret[1] = ret[0]; ret[0] = A[i]; } else if(A[i] < ret[1]){ ret[1] = A[i]; } } return ret; } // first question for Thurs 9:30AM, Thurs 8:00PM public static int[] makeRange (int A, int B){ int ret [] = new int[B-A+1]; for(int i = 0; i < ret.length; i++){ ret[i] = A + i; } return ret; } // first question for Thurs 11:00AM, Thurs 6:30PM public static int[][] rowSubtract (int [][] A, int [] V){ int ret [][] = new int [A.length] [A[0].length]; for(int i = 0; i < A.length; i++) for(int j = 0; j < A[0].length; j++) ret [i][j] = A[i][j] - V[j]; return ret;
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/31/2010 for the course CS 110 taught by Professor Cettei during the Spring '08 term at UVA.

Page1 / 3

Quiz2Answers - public class Quiz2Answers cfw_ /* * /...

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

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