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
SIZIF [17.4K]
3 years ago
14

Implement the function maxLoc(), which returns an iterator at the largest element in a list. template typename list::iterator ma

xLoc(list& aList); Write a program that tests maxLoc(), using the following declarations: int intArr[] = {23, 49, -3, 29, 17, 200, 38, 93, 40}; int intSize = sizeof(intArr)/sizeof(int); list intList(intArr,intArr+intSize); char chrArr[] = "Hello World!"; int chrSize = sizeof(chrArr); list chrList(chrArr,chrArr+chrSize); The program should repeatedly call maxLoc(), output the largest value, and then delete the value, until the list is empty.
Computers and Technology
1 answer:
Readme [11.4K]3 years ago
5 0

Answer:

See explaination

Explanation:

#include <iostream>

#include <iterator>

#include <list>

using namespace std;

list <int> :: iterator maxLoc(list<int>& alist){

list<int> :: iterator max;

list<int> :: iterator it;

int maxs = -199999999;

for (it = alist.begin(); it != alist.end();it++){

int c = *it;

if(maxs < c){

max = it;

maxs = *it;

}

}

alist.erase(max);

return max;

}

list <char> :: iterator maxLoc(list<char>& alist){

list<char> :: iterator max;

list<char> :: iterator it;

int maxs = -199999999;

for (it = alist.begin(); it != alist.end();it++){

char c = *it;

if(maxs < c){

max = it;

maxs = *it;

}

}

alist.erase(max);

return max;

}

int main() {

int intArr[] = {23, 49, -3, 29, 17, 200, 38, 93, 40};

int intSize = sizeof(intArr) / sizeof(int);

list <int> intlist(intArr, intArr + intSize);

list<int> :: iterator it;

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

list<int> :: iterator m = maxLoc(intlist);

cout << *m << endl;

}

char chrArr[] = "Hello World!";

int chrSize = sizeof(chrArr);

list<char> chrlist(chrArr, chrArr + chrSize);

for(int j = 0;j<chrSize;j++){

list<char> :: iterator m = maxLoc(chrlist);

cout << *m << endl;

}

}

You might be interested in
What devices are used to connect computers to a network?
ehidna [41]
You can use a hub, switch, or router
4 0
4 years ago
Select the correct answer.
ValentinkaMS [17]

Answer: typing keys

Explanation: it’s obvious...

8 0
4 years ago
which quotation from the story of the fisherman in the Arabian nights' entertainments supports the theme that cleverness trumps
Greeley [361]

Answer:

Vexed with having such a bad haul, when he had mended his nets, which the carcass of the butt had broken in several places, he threw them a second time

Explanation:

SORRY IF WRONG JUST TRYING TO GET BRAINLIEST TO LEVEL UP

6 0
4 years ago
In what year did commercial use of the Internet become available? 1991 1996 1999 2001
Shtirlitz [24]

1991 I hope its right


8 0
4 years ago
The purpose of a ________ is to extract data from operational systems and other sources, clean the data, and store and catalog t
NeTakaya

Answer:

The correct answer for the following question will be Data warehouse.

Explanation:

Data warehouse (DWH), is a facility provided to data analyze and for managing and controlling an organization's business intelligence tools, pull data from many sources together for survey and analysis. It helps to store the former information and allows making better information for organization. This is also known as Enterprise Data Warehouse (EDW)

3 0
3 years ago
Other questions:
  • You can select a paragraph y using the ____key.
    10·1 answer
  • Dani needs to present a mathematical formula to his audience. How should he start the process of adding an equation to a slide?
    5·1 answer
  • When a process becomes digital, it often becomes cheaper and the workflow becomes simpler. True False
    5·2 answers
  • While waiting to be seated at a restaurant, Jason receives a customer loyalty coupon through an app on his mobile phone for half
    7·1 answer
  • To properly insert a memory module, you must locate the direction of the ______ .
    14·1 answer
  • Define a pointer variable named daco that can be used for objects of the class Banana.
    14·2 answers
  • You insert a comment in a worksheet by using a command on the ____ tab on the Ribbon.
    13·1 answer
  • Preciso de ajuda urgente, é para amanhã cedo!!
    10·1 answer
  • If the code for JAVA is LCXC, what is the code for BASIC?
    12·1 answer
  • How do you print "Hello World" in the console with Python? Wrong Answers Only.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!