Modify a text file: $/practice-array-1.pde
$/practice-array-1.pde
////// practice-array-1.pde // Display all elements of an array (with bar charts, etc.) float [] a = { 99.1, 33.2, 344.3, 22.4, 66.7 }; int many= a.length; int nextX, nextY; // Coords of next display. final int FIRSTX=10, FIRSTY=20, SPACING=12; float big=100, multiplier; void setup() { size( 800,480); text("practice-array-1 // Display all elements of an array (with bar charts, etc.", 10, height-20 ); } void draw() // Show all values; { // big= biggest( a ); // Find biggest value in a. // big= biggest( a ); // Find biggest value in a. int k= whereBig( a ); big= a[ k ]; // Gets biggest value in a. multiplier= (width-90) / big; //scene(); show(); } void scene() { background( 255,255,200 ); } void show() //// Show elements of array. { nextX= FIRSTX; nextY= FIRSTY; for (int j=0; j
big) result= z[0] ; /// replace with bigger value. } return result; } int whereBig( float[] z ) // Return INDEX OF the biggest value in this array. { int w=0; for ( int j=0; j < z.length; j++) { if (z[j] > z[w]) w=j; // replace w with INDEX of bigger value! } return w; }