Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Generate and Transform Sequence | Algorithms
C++ STL Containers and Algorithms

bookChallenge: Generate and Transform Sequence

Compito

Swipe to start coding

Implement two functions:

  • generateSequence: takes an integer n and returns a std::vector<int> of size n filled with random values. Use std::generate to fill the vector. Generate random integers between 1 and 100 (inclusive).
  • squareElements: takes a const std::vector<int>& and returns a new vector where each element is the square of the corresponding input value. Use std::transform for this operation.

Soluzione

solution.cpp

solution.cpp

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 6
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me a real-world example?

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Generate and Transform Sequence

Scorri per mostrare il menu

Compito

Swipe to start coding

Implement two functions:

  • generateSequence: takes an integer n and returns a std::vector<int> of size n filled with random values. Use std::generate to fill the vector. Generate random integers between 1 and 100 (inclusive).
  • squareElements: takes a const std::vector<int>& and returns a new vector where each element is the square of the corresponding input value. Use std::transform for this operation.

Soluzione

solution.cpp

solution.cpp

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 6
single

single

some-alt