aboutsummaryrefslogtreecommitdiff
path: root/challenge-197/deadmarshal/d/ch1.d
blob: df659a5f1b2d444a64e2ccd61bbda897f9f2d292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import std.stdio:writeln;

void move_zero(int[] arr)
{
  int count = 0;
  for(int i = 0; i < arr.length; ++i)
    if(arr[i] != 0) arr[count++] = arr[i];
  while(count < arr.length) arr[count++] = 0;
}

void main()
{
  int[] a1 = [1,0,3,0,0,5];
  int[] a2 = [1,6,4];
  int[] a3 = [0,1,0,2,0];
  move_zero(a1);
  move_zero(a2);
  move_zero(a3);
  writeln(a1);
  writeln(a2);
  writeln(a3);
}