Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Vector Operations in Practice | Containers
C++ STL Containers and Algorithms

bookChallenge: Vector Operations in Practice

Oppgave

Swipe to start coding

Implement two functions:

  • Define a function named createSequence that takes an integer argument n and returns a std::vector<int> containing the numbers from 1 to n (inclusive), in order;
  • Define a function named sumVector that takes a const std::vector<int>& as an argument and returns the sum of its elements as an integer.

Løsning

solution.cpp

solution.cpp

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Vector Operations in Practice

Sveip for å vise menyen

Oppgave

Swipe to start coding

Implement two functions:

  • Define a function named createSequence that takes an integer argument n and returns a std::vector<int> containing the numbers from 1 to n (inclusive), in order;
  • Define a function named sumVector that takes a const std::vector<int>& as an argument and returns the sum of its elements as an integer.

Løsning

solution.cpp

solution.cpp

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

some-alt