วันศุกร์ที่ 3 ตุลาคม พ.ศ. 2557

write a function to create random values in an array 1

 

(duplicate values are allowed)

int [] value  = new int [10];

void setup () {
  size (230, 50);
  background (0);
  Random_value (15);
}
void Random_value (int space) {
  text ("{", 10, 30);
  for (int i = 0; i<value.length; i++) {
    value [i] = int (random (100));
  }
  for (int i = 0; i<value.length; i++) {
    if (i < value.length) {
      text (value[i], space, 30);
      space = space + 20;
      if (i<value.length-1) {
        text (",", space-5 , 30);
      }
    }
    if (i == value.length-1) {
      text ("}", 215, 30);
    }
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น