코딩Coding/Rust연습
-
Rust연습) Guessing Game in Rust코딩Coding/Rust연습 2021. 12. 4. 23:44
use colored::*; use rand::Rng; use std::cmp::Ordering; use std::io; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("The secret number is : {}", secret_number); loop { println!("Please input your guess. "); let mut guess = String::new(); io::stdin() .read_line(&mut guess) .expect("Failed to read line"); let guess: u32 = match guess.tr..
-
Rust연습_Fibonacci피보나치 출력코딩Coding/Rust연습 2021. 5. 13. 01:15
fn main() { let mut i = 0; let mut a = 0; let mut c = 0; let mut b = 1; while i 1 { c = b; //1//1/2//3 b = b + a; //1+0=1/1+1=2////3 a = c; //1//1//2 println!(" {}", b); i = i + 1; } else { println!(" {}", i); i = i + 1; } } } 결과 www.youtube.com/watch?v=WgWrqLwMIgU 12345678910111213141516171819fn main() { let mut i = 0; let mut a = 0; let mut c = 0; let mut b = 1; while i 1 { c = b..
-
-
Rust연습_Create a Calculator App러스트로 계산기 만들기-Engineer man코딩Coding/Rust연습 2021. 5. 11. 23:12
use std::io::{stdin, stdout, Write}; fn read(input: &mut String) { stdout().flush().expect("failed to flush"); stdin().read_line(input).expect("failed to read"); } fn main() { println!("Welcome to engineer man's calculator!"); println!("--------------------"); let mut num1 = String::new(); let mut num2 = String::new(); let mut operator = String::new(); println!("What is the first number?: "); re..
-
Rust연습 - 구조체 및 열거형을 사용하여 코드 수정(exercise-structs-enums)코딩Coding/Rust연습 2021. 5. 11. 17:49
struct Car { color: String, transmission: Transmission, convertible: bool, mileage: u32, } #[derive(PartialEq, Debug)] enum Transmission { Manual, SemiAuto, Automatic, } fn car_factory(color: String, transmission: Transmission, convertible: bool) -> Car { // To Do - Fix this part of the function to create a new Car object as requested by the client let car = Car { color: color, transmission: tra..
-
Rust연습_추리 게임 튜토리얼코딩Coding/Rust연습 2021. 5. 9. 01:02
use std::io; fn main() { println!("Guess the number!"); println!("Please input your guess."); let mut guess = String::new(); io::stdin() .read_line(&mut guess) .expect("Failed to read line"); println!("You guessed: {}", guess); } 결과 추리 게임 튜토리얼 - The Rust Programming Language (rinthel.github.io) 추리 게임 튜토리얼 - The Rust Programming Language 실습 프로젝트를 통해 러스트를 사용해 봅시다. 이번 장은 실제 프로젝트에서 몇몇 일반적인 Rust 개념이 ..