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 machine learning technique helps in answering the question
Zina [86]
I don’t know I need points :))))
4 0
4 years ago
Describe the positive and negative effects of Internet​
kvasek [131]

Answer:

pos-ugly

neg-gay

Explanation:

8 0
3 years ago
Read 2 more answers
" Which technique for representing numeric data uses the mantissa to hold the significant digits of a value?"
UkoKoshka [18]

Answer:

signed magnitude

Explanation:

A numeric value that is approximate consists of a mantissa and an exponent. The mantissa is a signed numeric value, so also is the exponent a signed integer that specifies the magnitude of the mantissa.

4 0
4 years ago
I need help with question 3 I’ll give brainliest
Semmy [17]

Answer:

D) Engineering and Technology

Explanation:

Brent Designs or <em>Engineers </em>the equipment or<em> Technology </em>that is used to keep the plant safe.

7 0
3 years ago
Read 2 more answers
A serial schedule:
Lina20 [59]

Answer:

B)

Explanation:

Is alwayd sorted sequentially in aceding order by transaction ID

6 0
3 years ago
Other questions:
  • Which formula returns TRUE, if the value in cell B1 is less than 40 and the value in C1 is less than 100?
    7·2 answers
  • If you are asked to bring in agile way of working into the way a meeting runs, which one among the listed options will you imple
    11·1 answer
  • What is wrong, logically, with the following code? if (x &gt; 10) System.out.println("Large"); else if (x &gt; 6 &amp;&amp; x &l
    11·1 answer
  • Sukhi needs to insert a container into her form to collect a particular type of information. Which object should she insert?
    6·1 answer
  • What does the term measure refer to in typography
    7·2 answers
  • Once you have a listing of every unique combination of salesperson, product and location, what Excel function would you use to c
    14·1 answer
  • What is word length in computer​
    10·2 answers
  • Suppose Alice and Bob are sending packets to each other over a computer network. SupposeTrudy positions herself in the network s
    11·1 answer
  • You can find synonyms and disciplinary jargon in the ______, _______, and ______ in your search results. You can then use these
    13·1 answer
  • As a hardware technician and knowing the internet components of the system unit, list any five(5) of such components.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!