Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program to find minumum of N numbers, #35

Open
ashwin-phadke opened this issue Dec 14, 2017 · 1 comment
Open

Program to find minumum of N numbers, #35

ashwin-phadke opened this issue Dec 14, 2017 · 1 comment

Comments

@ashwin-phadke
Copy link

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 }), })

@ranjithrajv
Copy link
Member

@ashwin-phadke there is an interesting project called 'Rust for undergrads' which is basically academic examples written in Rust, look into it.

https://github.com/swechaFSMI/Rust-for-undergrads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants