Physics, asked by Manikbhatia9195, 11 months ago

There are 'n' bags in a corner of a city and they have to be moved to the centre of the city by a solar vehicle. The vehicle starts shunting from morning, the vehicle can carry more load in the mornings than in the evening when sunlight would be dimmer. Given the details of items in the bag, sort the bag in descending so that the vehicle can safely carry it to the centre of the city. Use vector and map in stl. Also use the sort algorithm defined in stl.

Answers

Answered by thewordlycreature
0

A solar powered vehicle is a vehicle which is operated by using solar radiation. Solar powered vehicle is capable of carrying more load in the morning than in the evening because in the morning there is much intense solar radiation than in the evening when the solution becomes dimmer.

In the morning the solar powered vehicle should carry heavy weight material from one end of the city to the centre. While in the evening the solar powered vehicle should carry the low weight material from the other parts of city to the centre of the city.

Answered by Anonymous
0

Answer:

Explanation:

We need to use the input format  as -

Number of bags ‘n’

Name of bag1

Number of types of items in bag1, ‘t’

Weight of item1 in bag1

Number of item1 in bag1

Weight of item2 in bag1

Number of item2 in bag1

Weight of itemt in bag1

Number of itemt in bag1

Output Format

Print name of bags in sorted order.

Sorting must be done in descending order based on the weight of the bag.

The algorithm code -

#include

#include

#include

#include

using namespace std;

class bag

{

char name[30];

int num_Of_Items;

float item_Wt[20];

float item_Count[20];

public:

void get();

//print only name of bag

void print();

//Compute weight from details given

float compute();

};

bool wayToSort(int i, int j);

class solar

{

map<float,bag> m1;

vector v;

int num_Bags;

public:

//get details of bags and insert into map and vector

// In map, key – weight and value – details of bag

// In vector, weight of bags

void get();

void sort_Vec();

//print name of bags in sorted order

void print_In_Order();

};

Similar questions