/* ACM North Central Region, 1993-94 Problem G, Inventory Maintenance Ed Karrels, March 1996 */ #include typedef struct { char name[11]; int on_hand; float buy, sell; } Ware; int Read(char **name, int *i1, float *f1, float *f2) { static char str[20]; *name = str; scanf("%s", str); if (!strcmp(str, "report")) return 5; if (!strcmp(str, "new")) { scanf("%s %f %f", str, f1, f2); return 1; } else if (!strcmp(str, "delete")) { scanf("%s", str); return 2; } else if (!strcmp(str, "buy")) { scanf("%s %d", str, i1); return 3; } else if (!strcmp(str, "sell")) { scanf("%s %d", str, i1); return 4; } else { return 0; } } int Cmp(const void *av, const void *bv) { Ware *a = (Ware*)av; Ware *b = (Ware*)bv; return strcmp(a->name, b->name); } int Lookup(Ware w[], int nw, char *name) { int i; for (i=0; i