[ create a new paste ] login | about

Link: http://codepad.org/hpslrHHs    [ raw code | output | fork ]

D, pasted on Oct 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import std.stdio: writef, writefln;

struct Point { int x, y; }

Point[2] arr1 = [{0,0}, {0,1}];

Point[3][2] arr2 = [
  [{0,0}, {0,1}, {0,2}],
  [{1,0}, {1,1}, {1,2}]
];

void main() {
  foreach (i, point; arr1)
    writefln("Point(%d) = {%d, %d}", i, arr1[i].x, arr1[i].y);
  
  foreach(points; arr2) {
    foreach(point; points)
      writef("Point(%d, %d)\t", point.x, point.y);
    writefln();
  }
}


Output:
1
2
3
4
Point(0) = {0, 0}
Point(1) = {0, 1}
Point(0, 0)	Point(0, 1)	Point(0, 2)	
Point(1, 0)	Point(1, 1)	Point(1, 2)	


Create a new paste based on this one


Comments: