1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
elixir [45]
3 years ago
5

Write a C++ console program to do the following: 1. Define an array of ints with the ten elements { 0, 1,2,3, 4, 5, 6, 7, 8, 9 }

. 2. Define a vector with those ten elements. 3. Define a list with those ten elements. 4. Define a second array, vect
Computers and Technology
1 answer:
Gemiola [76]3 years ago
7 0

Answer:

#include<iostream>

#include <vector>

#include <list>

using namespace std;

int main(){

int a[10]={0,1,2,3, 4, 5, 6, 7, 8, 9 };

std::vector<int> v (&a[0],&a[0]+10);

std::list<int> l (&a[0],&a[0]+10);

int b[10];

for(int i=0;i<10;i++){

b[i]=a[i];

}

std::vector<int> v2(v);

std::list<int> l2(l);

for(int i=0;i<10;i++){

b[i]+=2;

}

for(int i=0;i<10;i++){

v2[i]+=3;

}

for (std::list<int>::iterator it = l2.begin(); it != l2.end(); it++)

*it=*it+5;

cout<<"Each containers value are: "<<endl;

cout<<"1st array: "<<endl;

for(int i=0;i<10;i++){

cout<<a[i]<<" ";

}

cout<<"\n 1st vector: \n";

for(int i=0;i<10;i++){

cout<<v[i]<<" ";

}

cout<<"\n 1st List is:\n";

for (std::list<int>::iterator it = l.begin(); it != l.end(); it++)

cout << *it << ' ';

cout<<"\n 2nd array: "<<endl;

for(int i=0;i<10;i++){

cout<<b[i]<<" ";

}

cout<<"\n 2nd vector:\n";

for(int i=0;i<10;i++){

cout<<v2[i]<<" ";

}

cout<<"\n 2nd list:\n";

for (std::list<int>::iterator it = l2.begin(); it != l2.end(); it++)

cout << *it << ' ';  

return 0;

}

Explanation:

  • Initialize an array, a vector and a list of type integer .
  • Create a 2nd array, vector, and list as a copy of the first array, vector, and list.
  • Increase the value of each element in the array by 2 , vector by 3 and list by 5.
  • Finally display the relevant results.
You might be interested in
Which of the following are common problems experienced with software applications?
dimulka [17.4K]
1. Incorrect Calculations 2. Incorrect data edits 3. Ineffective data edits 4. Incorrect coding/implementation of business rules 5. Inadequate software performance 6. Confusing or misleading data 7. Software that is difficult to use 8. Obsolete software 9. Inconsistent processing 10. Difficult to maintain and understand 11. Inadequate security controls
6 0
3 years ago
Provide an example where a company has demonetized a market or industry.
kondor19780726 [428]
Companies are shut down if copyrighted
4 0
3 years ago
GUYS THERE IS A HACKER IN BRAINLY PLEASE DONT PRESS ON THE WEBSITE THEY WILL HACK YOU.
Rudiy27

Answer:

okayyyyyyyyyyyyyyyyy

6 0
3 years ago
Read 2 more answers
Assume the user types in 7 for x and 2 for y. What is output by the
vladimir1956 [14]

Answer:

49

Explanation:

3 0
3 years ago
I am a bacterium. I cause stomach cramps and diarrhea. I am caused by eating rotten foods
ZanzabumX [31]

I think it's salmonella. : )

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which major milestones started off the progression that led to the modern computers we play games on now? What do you think affe
    14·1 answer
  • Ruby is creating a presentation. She wants each slide displayed at intervals of five seconds. Which feature in the presentation
    6·2 answers
  • Where will the CPU store data for easy access and quick retrieval during these computations?
    13·1 answer
  • Whats the size of a short bond paper in microsoft word?
    10·1 answer
  • Whats the wire that connects to the wifi box
    15·2 answers
  • What is not an option when a user is exporting contacts to share with others?
    10·1 answer
  • What are the benefits of writing functions that use parameters and return? Try to list at least two.
    12·1 answer
  • E-What is the important of Recycle bin?<br>Ans:​
    12·1 answer
  • Which browser feature will delete your history, cache, and cookies the moment you close the special window
    6·1 answer
  • Chantal has configured the network at her company's new headquarters with a number of VLANs. All devices joined to the individua
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!