Skip to content
Snippets Groups Projects
nested_ccp.jn 499 B
#[entry]
fn ccp_example(arg : f32[3]) -> f32 {
  let x : f32 = 2;
  if x < 3 {
    x = 1;
  } else {
    if x == 1 {
      x = 3;
    } else {
      x = 7;
    }
  }
  if false { for i = 0 to 3 by 1 { x = arg[i]; arg[i] = 0; } }
  return x;
}

#[entry]
fn median_array<n : usize>(arr : i32[n]) -> i32 {
  for i = 0 to n - 1 {
    for j = 0 to n - i - 1 {
      if arr[j] > arr[j+1] {
        let t = arr[j];
        arr[j] = arr[j+1];
        arr[j+1] = t;
      }
    }
  }

  return arr[n / 2];
}