This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
Scanner s = new Scanner(System.in);
int a[] = s.tokens()
.mapToInt(Integer::parseInt)
.toArray();
s.close();
@x = map {chomp; $_} <>;
<> returns lines from stdin.
Run a map over stdin to remove the newline (from the sometimes-named `it` variable) and stash the results in an array.
Run a map over stdin to remove the newline (from the sometimes-named `it` variable) and stash the results in an array.
a = (x.split() for x in stdin)
a = map(int, chain(*a))
let mut string = String::new();
io::stdin().read_to_string(&mut string)?;
let result = string
.lines()
.map(i32::from_str)
.collect::<Result<Vec<_>, _>>();
result is a Result<Vec<i32>, ParseIntError>.