B
B
Bartar2017-04-15 18:16:17
Rust
Bartar, 2017-04-15 18:16:17

Working with arrays. How to fill an array with data from the console and compare it with another array?

You need to fill the array with spells from the console, and then compare it with another array. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarkEld3r, 2017-04-20
@DarkEld3r

How did you try and what didn't work? And that sounds like a task from somewhere. Is it really necessary to do labs on the growth somewhere? (:
Well, many questions arise: do you really need an array? If so, what to do if you entered more numbers?
Well, in general, something like this:

use std::io;

fn main() {
    //let mut input = String::new();
    //io::stdin().read_line(&mut input).unwrap();

    let data1: Vec<i32> = input.split(' ').map(|x| x.parse().unwrap()).collect();
    let data2 = vec![1, 2, 3];
    if data1 == data2 {
        println!("equal!");
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question