Rust操练--while,continue,break

2020-11-09  本文已影响0人  万州客

基本功,走起~

一,代码

fn main() {
    let mut i = 0;
    while i <= 50 {
        i += 1;
       if i % 3 == 0 {continue;}
       if i * i > 400 {break;}
       print!("{} ", i * i);
    }
}

二,输出

> Executing task: cargo run <

   Compiling hello_rust v0.1.0 (D:\Code\hello_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.64s
     Running `target\debug\hello_rust.exe`
1 4 16 25 49 64 100 121 169 196 256 289 361 400 
Terminal will be reused by tasks, press any key to close it.

三,vscode编辑界面

2020-11-09 21_05_47-悬浮球.png
上一篇 下一篇

猜你喜欢

热点阅读