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
Abdhbhbhsbfhsbhcvdhcbsdbhsvhgvhdsgvfhsgdvfhgdsvghcghvc
Orlov [11]

Answer:

thats what i like daddy

ohhhh

Explanation:

6 0
4 years ago
Read 2 more answers
Change the function definition for myint so that xyzfunc uses the same memory locations for myint as in the calling program.
sattari [20]

Answer:

b) void xyzfunc (int &myint);

Explanation:

To use the same memory location as the variable in the calling function we have to pass the variable by reference means passing the same address to the function.So to do that we have use & operator which stands for address.

We will do this as following:-

void xyzfunc (int * myint);

Hence the answer is option b.

8 0
4 years ago
What types of tasks can you complete using Microsoft Excel (name and describe at least 3)
FrozenT [24]

Answer:

1) Data Entry and Storage. ...

2) Accounting and Budgeting. ...

3) Collection and Verification of Business Data. ...

4) Scheduling. ...

5) Build Great Charts. ...

6) Help Identify Trends. ...

7) Administrative and Managerial Duties. ...

9) Return on Investment.

8 0
3 years ago
Write c++ an algorithm to write a program to sort two numbers ascending or descending order​
In-s [12.5K]

Answer:

++ provides versions of these algorithms in the namespace std::ranges. Algorithms are the vast topic that covers topics from searching, sorting to min/max heaps. These can be categorized as:

Explanation of C++ Algorithm

Explanation:

4 0
3 years ago
Which of these statements correctly describes how to adjust an image on a slide ?
loris [4]

The correct answer is Choice D.

In order to adjust an image on a slide you can resize it by clicking on the boxes at the corner and then moving it in or out in order to change its size.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What career is likely to have to highest salary
    14·2 answers
  • Under which condition below would you expect a glassy extrusive rock like obsidian to form?
    10·2 answers
  • The following slide was created as part of a presentation that trains new employees how to use the scheduling and calendar softw
    14·2 answers
  • Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every t
    6·1 answer
  • Which best explains a password attached to a document?
    7·1 answer
  • Select the correct answer.
    11·1 answer
  • Assembly language program wich indetify largest number from the five elements 51,44,67,30,99​
    13·1 answer
  • Horizontal and vertical flips are often used to create ___.
    12·1 answer
  • When a program uses a ____, it reads all the records in the file from beginning to end, processing them one at a time. Group of
    5·1 answer
  • If the cpu is fast but the bus speed is slow, that condition is called?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!