#include #include #define SZ 7 int queue[SZ]; int front = 0; int rear = 0; int isEmpty() { return (rear == front); } int isFull() { return ((rear + 1) % SZ == front); } int deque() { if (isEmpty() == 1) { return -999; } int temp = queue[front]; front = (front + 1) % SZ; return temp; } void enque(int n) { int if100 = 0; if (isFull() == 1) { return; } if (n == 100) { while (isEmpty() == 0) { if100..
#include #include #define SZ 5 int queue[SZ]; int front = 0; int rear = 0; int isEmpty() { return (rear == front); } int isFull() { return ((rear + 1) % SZ == front); } void enque(int n) { if (isFull() == 1) { return; } queue[rear] = n; rear = (rear + 1) % SZ; return; } int deque() { if (isEmpty() == 1) { return -999; } int temp = queue[front]; front = (front + 1) % SZ; return temp; } int main(v..
// Singly Linked List #include #include int in; //node 구조체정의 struct node { int data; struct node *next; }; struct node* head = 0; //sLL에 추가하는함수 void addToSLL(int data) { struct node *cur; cur = (struct node*)malloc(sizeof(struct node)); cur->data = data; cur->next = 0; //1.SLL이 empty if (head == 0) { head = cur; return; } //2 else //2.1끝을찾자 //2.2끝에 붙이자 { struct node* lastnode = head; while (last..
#include #include int in; //node 구조체정의 struct node { int data; struct node *next; }; struct node* head = 0; //sLL에 추가하는함수 void addToSLL(int data) { struct node *cur; cur = (struct node*)malloc(sizeof(struct node)); cur->data = data; cur->next = 0; //1.SLL이 empty if (head == 0) { head = cur; return; } //2 else //2.1끝을찾자 //2.2끝에 붙이자 { struct node* lastnode = head; while (lastnode->next != 0) { las..
#include #include //node 구조체정의 struct node { int data; struct node *next; }; struct node* head = 0; //sLL에 추가하는함수 void addToSLL(int data) { struct node *cur; cur = (struct node*)malloc(sizeof(struct node)); cur->data = data; cur->next = 0; //1.SLL이 empty if (head == 0) { head = cur; return; } //2 else //2.1끝을찾자 //2.2끝에 붙이자 { struct node* lastnode = head; while (lastnode->next != 0) { lastnode = ..
#include #include struct node { int data; struct node *next; }; struct node *head; void addToSLL(int n) { struct node *cur; cur = (struct node *)malloc(sizeof(struct node)); cur->data = n; cur->next = 0; if (head == 0) { head = cur; return; } else { struct node *temp = head; while (temp->next != 0) { temp = temp->next; } temp->next = cur; return; } } void showSLL() { struct node *cur = head; whi..