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
bija089 [108]
3 years ago
10

Consider a company that needs to sort an array of structures of type Customer by balance, with the largest balance first. Here i

s the definition of the Customer structure: struct Customer { string name ; double balance ; } In real life the Customer array may have thousands of data members and occupy a large area of memory, making it computationally expensive to move Customer objects around while sorting . In this problem, you will create an array of only 10 structures, say Customer data[10]. You also can define an auxiliary array Customer *pData[10], setting each entry of pData [k] to point to the corresponding entry of data[k]. Write a program that sorts the array of pointers so that when you go through pData in increasing order of index k, the entries pData[k] point to Customer objects in decreasing order by balance, meaning that pdata[0] now points to the customer with the highest balance, and pData[9] points to the customer with the smallest balance.
Computers and Technology
1 answer:
8090 [49]3 years ago
4 0

Answer:

#include <iostream>

#include <string>

#include <cstring>

#include <cstdlib>

using namespace std;

struct Person

{

string name;

int age;

};

int main()

{

struct Person data[10];

struct Person *pData[10],*temp;

string names[] = {"a","b","c","g","z","l","p","q","r","w"};

int num[] = {4,6,34,8,13,90,33,22,18,23};

for(int i=0;i<9;i++)

{

data[i].name = names[i];

data[i].age = num[i];

pData[i] = &data[i];

}

for(int i=0;i<9;i++)

{

for(int j=i+1;j<9;j++)

{

if(pData[i]->name.compare(pData[j]->name)>0)

{

temp = pData[i];

pData[i] = pData[j];

pData[j] = temp;

}

}

}

for(int i=0;i<9;i++)

{

cout<<pData[i]->name<<" "<<pData[i]->age<<endl;

}

}

Explanation:

The line #include <iostream> initializes the program.

This program created an array of only 10 structures, Customer data. Also defined an auxiliary array Customer *pData.

The program uses these parameters to sorts the array of pointers so that when you go through pData in increasing order of index k, the entries pData[k] point to Customer objects in decreasing order by balance, meaning that pdata[0] now points to the customer with the highest balance, and pData[9] points to the customer with the smallest balance.

You might be interested in
What are the advantages of cloud computing over computing on premises?
Verdich [7]

Answer:

answer my question

Explanation:

<h3>open my account. i need help.</h3>
3 0
2 years ago
When you use a business class with an object data source, the business class Group of answer choices must have attributes that m
DedPeter [7]

Answer: must have public properties that match the names of the bound fields

Explanation:

When a business class is used with an object data source, the business class must have public properties that match the names of the bound fields.

Having an attribute which match the names of the bound fields isn't necessary as well as having a constructor with parameters that match the names of the bound fields

Therefore, the correct option is B.

3 0
3 years ago
Small robots that can move around on the surface of a planet are called space shuttles.
PolarNik [594]

b:false because space shuttles orbit around a planet in outer space



3 0
3 years ago
Read 2 more answers
Pls help brainliest
Anastasy [175]

the answer to the question is c. i hope this helps.

3 0
3 years ago
Dennis is driving a car with his family onboard. His children are sitting on the backseat. They have a tablet and want to watch
Mice21 [21]

Answer:

A and D could work

Explanation:

they do basically does the same thing!!

8 0
3 years ago
Other questions:
  • Which of the following is a useful policy to minimize waste and mistakes?
    6·1 answer
  • What is the internet?
    5·2 answers
  • A large IPv4 datagram is fragmented into 4 fragments at router 1 to pass over a network with an MTU of 1500 bytes. Assume each f
    15·1 answer
  • All nuclear energy results in the rapid release of energy, such as in atomic bombs. true or false
    8·1 answer
  • Julie is trying to decide weather or not to add a color scheme to her presentation and she asks you for your advice u should adv
    9·1 answer
  • A powerboat is about to cross paths with a sailboat under sail. What should the powerboat do
    5·1 answer
  • Data aggregate functions
    6·1 answer
  • A ______________ is a way of taking a screenshot or a picture of your computer screen. ​
    14·1 answer
  • Anyone want to play mine mincraft w/ me?
    9·1 answer
  • Checking for and correcting errors may need to be done numerous during which of the following phases of the software development
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!