This website works better with JavaScript.
Home
Explore
lain.church
Help
Register
Sign In
cerealxp
/
sum
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Wiki
Activity
Browse Source
initial
master
Papaito
1 year ago
commit
9f295fafdd
6 changed files
with
30 additions
and
0 deletions
Split View
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
View File
@@ -0,0 +1 @@
/target
+ 7
- 0
Cargo.lock
View File
@@ -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
View File
@@ -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
View File
+ 0
- 0
main.rs
View File
+ 14
- 0
src/main.rs
View File
@@ -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…
Cancel
Save