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

bookChallenge: Vector Operations in Practice

Aufgabe

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ösung

solution.cpp

solution.cpp

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 2
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you explain this in simpler terms?

Can you give me an example?

What are the main benefits or drawbacks?

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Vector Operations in Practice

Swipe um das Menü anzuzeigen

Aufgabe

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ösung

solution.cpp

solution.cpp

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 2
single

single

some-alt