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]
2 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]2 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 is a massive online storage that allows for Access by any internet-connected device running web browser. use for Less priva
Paladinen [302]
I recommend Google Drive, it allows up to 15gb of free storage. You can access it anywhere since it is fromGoogle. Another one you can try is Dropbox which only allows up to 2gb.
8 0
3 years ago
Brainliest
olya-2409 [2.1K]

Answer:

browsing history

Explanation:

....

6 0
2 years ago
Read 2 more answers
Which lighting technique can often heighten a dramatic story?
Elina [12.6K]

Answer:

side or back lighting

Explanation:

big brain

6 0
3 years ago
To instruct Oracle11 g to sort data in ascending order, enter ____ after the column name in the ORDER BY clause.
Paha777 [63]

Answer:

A. ASC

Explanation:

In Oracle11 g ORDER BY clause is used to sort data andit is also used in mysql ,ms access.Though we not to mention ASC to sort in increasing order because by default it sorts the data in ascending order if we do not mention ASC or DESC.To sort in descending order we have to mention DESC.

So the correct answer to this question is ASC.

7 0
3 years ago
Read 2 more answers
The variable sentence stores a string. Write code to determine how many words in sentence start and end with the same letter, in
irina [24]

Answer:

sentence = "hello wow a stores good"

same_letter_count = 0

sentence_list = sentence.split()

for s in sentence_list:

   if s[0] == s[-1]:

       same_letter_count += 1

print(same_letter_count)

Explanation:

*The code is in Python.

Initialize the sentence with a string

Initialize the same_letter_count as 0

Split the sentence using split method and set it to the sentence_list

Create a for loop that iterates through the sentence_list. If the first and last of the letters of a string are same, increment the same_letter_count by 1

When the loop is done, print the same_letter_count

4 0
3 years ago
Other questions:
  • You bought a monochrome laser printer two years ago. The printer has gradually stopped feeding paper. Which printer component sh
    14·1 answer
  • Cryptolocker is an example of what type of malware?
    11·1 answer
  • What are the first two lines of defense a company should take when addressing security risks?
    10·1 answer
  • (1) In Tamara's science class, the students are learning Which sentence shows an action that is extrinsically
    7·1 answer
  • You buy a new workstation that features an embedded RAID controller on the motherboard. You want to setup hardware RAID 10. How
    10·2 answers
  • A Raycast returns a float that tells you how far away an Object is
    8·1 answer
  • Implement a recursive program that takes in a number and finds the square of that number through addition. For example if the nu
    5·1 answer
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • On the Format tab, which group allows you to select a different font for a chart?
    7·2 answers
  • The most common technique for using an appropriate synchronization mechanism to serialize the accesses to prevent errors is to a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!