I have been trying to code for the program that finds the minimum number from the numbers that we have taken from user .
ALGO:
1)User enters a number .
2)That number is referred to as the number of inputs the user will give.
3)Compare the inputs find the minimum and display.
And this is how far I have gotten :
`The program here is to find minimum from n numbers, could not do much further, guess I need the undergrad course first , anyways little help
` use std::io;
fn main() {
println!("Program to find minimum of N numbers");
let _a = [0; 30];
let minimum=0;
let size=0;
let c=0;
let location = 5;
println!("Enter the number of elements: ");
let mut size = String::new();
io::stdin()
.read_line(&string size)
.expect("Error reading number");
println!("Enter the numbers: ");
for _c in 1..size{
.read_line(&mut _a[size])
.expect("Error reading number"); }`
Solution proposed by Vighneshwar did not work or maybe I am not doing it right!
vec.push(1) .. for n values vec.into_iter().fold(None, |min, x| match min { None => Some(x), Some(y) => Some(if x < y { x } else { y }), })
I have been trying to code for the program that finds the minimum number from the numbers that we have taken from user . ALGO: 1)User enters a number . 2)That number is referred to as the number of inputs the user will give. 3)Compare the inputs find the minimum and display.
And this is how far I have gotten :
`The program here is to find minimum from n numbers, could not do much further, guess I need the undergrad course first , anyways little help
` use std::io;
Solution proposed by Vighneshwar did not work or maybe I am not doing it right!
vec.push(1) .. for n values vec.into_iter().fold(None, |min, x| match min { None => Some(x), Some(y) => Some(if x < y { x } else { y }), })