Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- typedef struct {
- int code;
- } Prod;
- #define LEN_MAX 100
- typedef struct {
- Prod prods[LEN_MAX];
- int len;
- } ProdList;
- #define NAME_MAX 25
- typedef struct {
- char name[NAME_MAX];
- ProdList plist;
- } Store;
- typedef struct StoreNode {
- Store store;
- struct StoreNode* nxt;
- } StoreNode;
- typedef struct {
- StoreNode* first;
- StoreNode* last;
- } StoreList;
- StoreNode* newStoreNode(const Store *const store, StoreNode* nxt) {
- StoreNode* node = (StoreNode*)malloc(sizeof(StoreNode));
- if (node == NULL) {
- perror("");
- exit(EXIT_FAILURE);
- }
- node->store = *store;
- node->nxt = nxt;
- return node;
- }
- void initStoreList(StoreList* storeList) {
- storeList->first = storeList->last = NULL;
- }
- void deleteProductByCode2(ProdList* plist, int code) {
- for (int i = 0; i < plist->len; i++) {
- if (plist->prods[i].code == code) {
- for (int j = i + 1; j < plist->len; j++) {
- plist->prods[j - 1] = plist->prods[j];
- }
- i--;
- plist->len--;
- }
- }
- }
- void deleteProductByCode(StoreList* storeList, int code) {
- for (StoreNode* node = storeList->first; node; node = node->nxt) {
- deleteProductByCode2(&node->store.plist, code);
- }
- }
- int main(void) {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement