We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Structs and Enums
- Post Transition
- Discussions
Post Transition
Post Transition
Sort by
recency
|
129 Discussions
|
Please Login in order to post a comment
Best online platform to buy machines Online. Discover Machine Yantra, your one-stop solution for all your machinery needs. From industrial equipment to home appliances, we offer a wide range of top-notch products from trusted brands at competitive prices.
.c
When looking for the best 2-ton split AC in India, consider a model that stands out for its exceptional cooling efficiency, energy-saving features, and durability. Electronic Paradise is the best electronics store where you can buy the best 2 ton spilt ac at reasonable price. Buy Now!
include
include
define MAX_STRING_LENGTH 6
struct package { char* id; int weight; };
typedef struct package package;
struct post_office { int min_weight; int max_weight; package* packages; int packages_count; };
typedef struct post_office post_office;
struct town { char* name; post_office* offices; int offices_count; };
typedef struct town town;
void print_all_packages(town t) { printf("%s:\n",t.name); for(int i=0 ; i
void send_all_acceptable_packages(town* source, int source_office_index, town* target, int target_office_index) {
post_office* source_office = &(source->offices[source_office_index]); post_office* target_office = &(target->offices[target_office_index]);
}
town town_with_most_packages(town* towns, int towns_count) { town most_packages_town = towns[0]; int max_packages = 0;
}
town* find_town(town* towns, int towns_count, char* name) { for (int i = 0; i < towns_count; i++) { if (strcmp(towns[i].name, name) == 0) { return &(towns[i]); } } return NULL; }
int main() { int towns_count; scanf("%d", &towns_count); town* towns = malloc(sizeof(town)*towns_count); for (int i = 0; i < towns_count; i++) { towns[i].name = malloc(sizeof(char) * MAX_STRING_LENGTH); scanf("%s", towns[i].name); scanf("%d", &towns[i].offices_count); towns[i].offices = malloc(sizeof(post_office)*towns[i].offices_count); for (int j = 0; j < towns[i].offices_count; j++) { scanf("%d%d%d", &towns[i].offices[j].packages_count, &towns[i].offices[j].min_weight, &towns[i].offices[j].max_weight); towns[i].offices[j].packages = malloc(sizeof(package)*towns[i].offices[j].packages_count); for (int k = 0; k < towns[i].offices[j].packages_count; k++) { towns[i].offices[j].packages[k].id = malloc(sizeof(char) * MAX_STRING_LENGTH); scanf("%s", towns[i].offices[j].packages[k].id); scanf("%d", &towns[i].offices[j].packages[k].weight); } } } int queries; scanf("%d", &queries); char town_name[MAX_STRING_LENGTH]; while (queries--) { int type; scanf("%d", &type); switch (type) { case 1: scanf("%s", town_name); town* t = find_town(towns, towns_count, town_name); print_all_packages(t); break; case 2: scanf("%s", town_name); town source = find_town(towns, towns_count, town_name); int source_index; scanf("%d", &source_index); scanf("%s", town_name); town* target = find_town(towns, towns_count, town_name); int target_index; scanf("%d", &target_index); send_all_acceptable_packages(source, source_index, target, target_index); break; case 3: printf("Town with the most number of packages is %s\n", town_with_most_packages(towns, towns_count).name); break; } } return 0; }