Jump to content

Cistercian numerals: Difference between revisions

m
→‎{{header|Rust}}: remove unneeded decorations
m (→‎{{header|Rust}}: remove unneeded decorations)
Line 5,029:
 
/// initialize CANVAS
unsafe fn init_n() {
for i in 0..GRID_SIZE {
for j in 0..GRID_SIZE {
unsafe { CANVAS[i][j] = ' '; }
}
unsafe { CANVAS[i][5] = '#'; }
}
}
 
/// draw horizontal
unsafe fn horizontal(c1: usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r][c] = '#'; }
}
}
 
/// draw vertical
unsafe fn vertical(r1: usize, r2: usize, c: usize) {
for r in r1..=r2 {
unsafe { CANVAS[r][c] = '#'; }
}
}
 
/// draw diagonal NE to SW
unsafe fn diag_d(c1 : usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r + c - c1][c] = '#'; }
}
}
 
/// draw diagonal SE to NW
unsafe fn diag_u(c1: usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r + c1 - c][c] = '#'; }
}
}
 
/// Mark the portions of the ones place.
unsafe fn draw_ones(v: i32) {
match v {
1 => horizontal(6, 10, 0),
Line 5,083:
 
/// Mark the portions of the tens place.
unsafe fn draw_tens(v: i32) {
match v {
1 => horizontal(0, 4, 0),
Line 5,099:
 
/// Mark the portions of the hundreds place.
unsafe fn draw_hundreds(hundreds: i32) {
match hundreds {
1 => horizontal(6, 10, 14),
Line 5,115:
 
/// Mark the portions of the thousands place.
unsafe fn draw_thousands(thousands: i32) {
match thousands {
1 => horizontal(0, 4, 14),
Line 5,131:
 
/// Mark the char matrix for the numeral drawing.
unsafe fn draw(mut v: i32) {
let thousands: i32 = v / 1000;
v %= 1000;
Line 5,152:
}
 
/// Test the drawings as outputoutout to stdout.
fn test_output(n: i32) {
println!("{n}");
init_n();
draw(n);
unsafe {
init_n();
draw(n);
for line in CANVAS.iter() {
for c in line.iter() {
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.