Pure Programmer
Blue Matrix


Cluster Map

Project: Multiplication Table

Write a program to print a multiplication table from 2s to 12s. The numbers 2-12 should be printed across the column heading and 2-12 should be printed at the beginning of each row. Use the format() function with integers to compute and fill in the results of the table.

Output
$ rustc MultiplicationTable4.rs error: unknown format trait `d` --> MultiplicationTable4.rs:13:31 | 13 | print!("{}", format!(" {0:3d}", y)); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error: unknown format trait `d` --> MultiplicationTable4.rs:24:30 | 24 | print!("{}", format!("{0:2d} |", x)); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error: unknown format trait `d` --> MultiplicationTable4.rs:28:33 | 28 | print!("{}", format!(" {0:3d}", x * y)); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error[E0425]: cannot find function `repeat` in this scope --> MultiplicationTable4.rs:19:17 | 19 | println!("{}", repeat('-',4 * 13)); | ^^^^^^ not found in this scope | help: consider importing one of these items | 7 + use std::io::repeat; | 7 + use std::iter::repeat; | error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0425`.

Solution