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]
2 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]2 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
The Spanning Tree Protocol operates at the Network layer of the OSI model.
BigorU [14]

Answer:

False

Explanation:

The Spanning Tree Protocol operates at the Data link layer of the OSI model.

Spanning Tree Protocol (STP) is a bridge and switch (Layer 2 protocol). The STP specification is IEEE 802.1D. STP's primary aim is to guarantee that when you have redundant routes in your network, you do not generate loops. Loops to a network are fatal.

6 0
3 years ago
How do you know if something is in the public domain
liraira [26]
You can start by looking at the date. Anything made before 1923, no matter what, will be definitely in the public domain. ... Most times, it's impossible to determine whether something is in the public domain just by the date. There are three ways you can find out definitively whether a work is in the public domain.
8 0
3 years ago
Complete the steps for saving a presentation as a poi file,
mars1129 [50]

Answer:

Click on the F

Copy & Print

Next, click on

Last, click

Send

Save As

Explanation:

This is because save means it will save your file as the same you have made but drop do means to cut or don't save the file that's why it should be the second one means:Click on the F

Copy & Print

Next, click on

Last, click

Send

Save As

4 0
2 years ago
Write a function called first_last that takes a single parameter, seq, a sequence. first_last should return a tuple of length 2,wh
motikmotik

Answer:

The Python code with the function is given below. Testing and output gives the results of certain chosen parameters for the program

Explanation:

def first_last(seq):

   if(len(seq) == 0):

       return ()

   elif(len(seq) == 1):

       return (seq[0],)

   else:

       return (seq[0], seq[len(seq)-1])

#Testing

print(first_last([]))

print(first_last([1]))

print(first_last([1,2,3,4,5]))

# Output

( )

( 1 , )

( 1 , 5 )

5 0
2 years ago
How does a computer work
ivann1987 [24]

Answer:

computer works on electricity

Explanation:

6 0
2 years ago
Other questions:
  • An array UnsortedInt consists of integers in random order. Another array SortedInt consists of a sorted list of integers.
    13·1 answer
  • What does subscribing to a website’s RSS feed provide to a subscriber?
    10·1 answer
  • Which of the following would be a tradeoff of a scientific advancement that enables us to catch fish from the ocean faster than
    5·1 answer
  • Weather satellites orbit Earth at an altitude of 1,400,000 meters. What is this altitude in kilometers?
    7·1 answer
  • ____ devices are high-performance storage systems that are connected individually to a network to provide storage for the comput
    12·1 answer
  • Casey, a woodworker, is developing his own website. He plans to use the site as a means of selling his handmade furniture. While
    10·1 answer
  • Are computer virus and human virus the same​
    6·1 answer
  • The use of Quick Styles is a great way to save
    15·1 answer
  • Write a qbasic program to design any simple software with output ​
    5·1 answer
  • Select the correct answer.<br> What do you understand by "exposition"?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!