#include #include #include #define MAX 1000 #define SIZE 101 struct pizza { char name[SIZE]; float price; }; int main() { struct pizza list[MAX]; int count = 0; char name[SIZE]; char price_str[SIZE]; float price; while (1) { if (fgets(name, SIZE, stdin) == NULL) break; name[strcspn(name, "\n")] = 0; if (strlen(name) == 0) break; if (fgets(price_str, SIZE, stdin) == NULL) break; price_str[strcspn(price_str, "\n")] = 0; if (sscanf(price_str, "%f", &price) != 1) break; if (price <= 0) break; strcpy(list[count].name, name); list[count].price = price; count++; if (count >= MAX) break; } for (int i = 0; i < count - 1; i++) { for (int j = 0; j < count - i - 1; j++) { if (list[j].price > list[j + 1].price || (list[j].price == list[j + 1].price && strcmp(list[j].name, list[j + 1].name) > 0)) { struct pizza temp = list[j]; list[j] = list[j + 1]; list[j + 1] = temp; } } } for (int i = 0; i < count; i++) { printf("%s\n%.6f\n", list[i].name, list[i].price); } return 0; }