วันเสาร์ที่ 21 กันยายน พ.ศ. 2556

Matrix calculation




void setup() {
  background(2);
  int[][] a = { {1,2},{2,1}};
  int[][] b = {{5,4},{4,5}};
  int[][] cul = new int[2][2];                                            
  int x=30;
  int y=50;
  int i=0;
  int j=0;
  while (i<a.length) {
    while(j<a[i].length) {
      cul[i][j] = a[i][j]+b[i][j];
      textSize(15);
      text(" "+cul[i][j], x, y);
      x=x+20;
      j++;
    }
    y=y+20;
    i++;
  }
}

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

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