美文网首页
Rust操练--while,continue,break

Rust操练--while,continue,break

作者: 万州客 | 来源:发表于2020-11-09 21:08 被阅读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

相关文章

网友评论

      本文标题:Rust操练--while,continue,break

      本文链接:https://www.haomeiwen.com/subject/ubprbktx.html