자료구조_c언어_서클 큐_circleQueue_02
2021. 7. 19. 14:37ㆍ개발하는중/자료구조
728x90
반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #include <stdio.h> #include <malloc.h> #include <string.h> #include <Windows.h> #define EMPTY 0 typedef struct Node { char menu[30]; int price; struct Node *link; }ND; ND *front = EMPTY; ND *rear = EMPTY; int totalMoney = 0; int isEmpty(); int showMenu(); void addMenu(); void checkAll(); void orderList(); void orderFinish(); int main() { while (1) { system("cls"); int select = showMenu(); switch (select) { case 1: addMenu(); break; case 2: checkAll(); break; case 3: orderList(); break; case 4: orderFinish(); break; case 5: printf("프로그램 종료 !\n"); exit(0); default: printf("잘못 입력 !\n"); } system("pause"); } } int isEmpty() { if (front == EMPTY && rear == EMPTY) { printf("메뉴 없음"); return 1; } return 0; } void checkAll() { printf("총 판매액:%d원\n", totalMoney); } void orderFinish() { if (isEmpty()) return; ND *instance = front; printf("메뉴 조리 완료(%s,%d원)\n", instance->menu, instance->price); front = instance->link; if (front == EMPTY) front = rear = EMPTY; totalMoney += instance->price; free(instance); } void orderList() { if (isEmpty()) return; ND *instance = front; while (instance != EMPTY) { printf("메뉴명:%s,가격:%d\n", instance->menu, instance->price); instance = instance->link; } } ND *makeNode() { ND *instance = (ND*)malloc(sizeof(ND)); printf("메뉴:"); scanf("%s", instance->menu); printf("가격:"); scanf("%d", &instance->price); instance->link = EMPTY; return instance; } | cs |
728x90
'개발하는중 > 자료구조' 카테고리의 다른 글
자료구조_c언어_tree (0) | 2021.08.25 |
---|---|
자료구조_c언어_circularLinkedList_01 (0) | 2021.08.25 |
자료구조_c언어_linkedList_02 (0) | 2021.05.25 |
자료구조_c언어_linkedList (0) | 2021.05.20 |
자료구조_c언어_linked (0) | 2021.05.18 |