//Jose M. Pena //project 5 float[] jmp; //int[] a= { 55, 22, 33, 77, 11, 99, 88, 66, 44 }; int many; //= a.length; int showX, showY; void setup(){ size(900, 700); smooth(); jmp= new float[20]; many= jmp.length; fillRandom( jmp, many ); //// float big; // Find the biggest number. big= jmp[0]; for (int j=0; j big) big= jmp[j]; } // Output the result. println("Biggest: "+big); fill(0,0,0); text("Biggest value in array: ", 10,50); text(big, 10,62); } void draw(){ background(0); text("Type 'f' to fill array with new values", 500,100); text("type 's' to sort arrays",50,100); showX=50;//x location of arrays showY=200;//y location of arrays showArray(jmp,many); } void keyPressed() // Which key? { if (key == 'f') // Random { fillRandom( jmp, many ); } if (key=='s') { background(255,127,255); text("SORTED ARRAY:", 10,10); showY= 50; //// Sort the array. sortArray(jmp, many); //// Display array, showArray(jmp, many); } } void fillRandom( float[] z, int m ) //// Fill with random #s { for (int j=0; j1 ) { //// Find biggest and move it to the end. int k= whereBig( jmp, n ); swap( jmp, k, n-1 ); // Move biggest to end. n--; // Now, shrink the array. } } int whereBig( float jmp[], int n ) { //// Return index of biggest. int w= 0; //// Start with first element. for (int j=1; j jmp[w]) w= j; } return w; } void swap( float jmp[], int i, int j ) { //// Swap 2 elements of an array. float tmp; tmp= jmp[i]; jmp[i]= jmp[j]; jmp[j]= tmp; }