This website works better with JavaScript.
首頁
探索
lain.church
說明
註冊
登入
cerealxp
/
sum
關註
1
收藏
0
複製
0
程式碼
問題管理
0
合併請求
0
版本發佈
0
Wiki
Activity
瀏覽代碼
initial
master
Papaito
1 年之前
當前提交
9f295fafdd
共有
6 個文件被更改
,包括
30 次插入
和
0 次删除
分割檢視
Diff Options
Show Stats
Download Patch File
Download Diff File
+1
-0
.gitignore
+7
-0
Cargo.lock
+8
-0
Cargo.toml
+0
-0
cargo
+0
-0
main.rs
+14
-0
src/main.rs
+ 1
- 0
.gitignore
查看文件
@@ -0,0 +1 @@
/target
+ 7
- 0
Cargo.lock
查看文件
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "sum"
version = "0.1.0"
+ 8
- 0
Cargo.toml
查看文件
@@ -0,0 +1,8 @@
[package]
name = "sum"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+ 0
- 0
cargo
查看文件
+ 0
- 0
main.rs
查看文件
+ 14
- 0
src/main.rs
查看文件
@@ -0,0 +1,14 @@
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let sum: u32 = stdin
.lock()
.lines()
.map(|line| -> u32 {
let num: u32 = line.unwrap().parse().unwrap_or(0);
num
}).sum();
println!("{}", sum);
}
Write
Preview
Loading…
取消
儲存