Small example with "Hello world!"

This commit is contained in:
2016-05-29 11:59:11 +02:00
parent 9be1d3a064
commit 213b6c2291

View File

@@ -1,8 +1,26 @@
use std::i32;
fn main() {
println!("{:?}", get_byte(2));
let buf = "Hello world!";
let mut i : i32 = 0;
for b in buf.chars() {
println!("{:?}", b);
for n in 0..i32::MAX {
if b == get_byte(n) {
i = n;
break;
}
}
fn get_byte(id: i32) -> u8 {
println!("{}", i);
}
}
fn get_byte(id: i32) -> char {
let pid : f64 = 4.0 * series(1, id) - 2.0 * series(4, id) - series(5, id) - series(6, id);
let mut y : f64 = (pid - (pid as i32) as f64 + 1.0).abs();
@@ -15,7 +33,7 @@ fn get_byte(id: i32) -> u8 {
let second : u8 = y as u8;
(first << 4) | second
((first << 4) | second) as char
}
fn series(m: i32, id: i32) -> f64 {