1. Queue in Array

#include <stdio.h>
#include <stdlib.h>

#define SIZE 10000
#define INF		99999

int queue[SIZE];
int front = 0;
int rear = 0;

void push(int data) {
	if (rear >= SIZE - 1) {
		printf("Queue Overflow !!");
		return;
	}
	queue[rear++] = data;
}

int pop() {
	if (front == rear) {
		printf("Queue Underflow !!");
		return -INF;
	}

	return queue[front++];
}

void show() {
	printf("Front Of Queue \n");
	for (int i = front; i < rear; i++) {
		printf("%d \n", queue[i]);
	}
	printf("Rear Of Queue \n");
}

int main() {
	push(2);
	push(1);
	push(5);
	push(7);
	push(6);
	pop();
	push(8);
	pop();
	push(3);
	show();
	system("pause");
}

 

2. Queue in LinkedList

#include <stdio.h>
#include <stdlib.h>

#define INF		99999

typedef struct {
	int data;
	struct Node *next;
}Node;

typedef struct {
	struct Node *front;
	struct Node *rear;
	int count;
} Queue;

void push(Queue *queue, int data) {
	Node *node = (Node*)malloc(sizeof(Node));
	node->data = data;
	node->next = NULL;

	if (queue->count == 0) {
		queue->front = node;
	}
	else {		  
		Node *rearNode = (Node*)malloc(sizeof(Node));
		rearNode = queue->rear;
		rearNode->next = node;
	}			  
	queue->rear = node;	
	queue->count++;
}

int pop(Queue *queue) {
	if (queue->count == 0) {
		printf("Queue underflow !! \n");
		return -INF;
	}

	Node *node = (Node*)malloc(sizeof(Node));
	node = queue->front;
	int data = node->data;
	queue->front = node->next;
	free(node);

	queue->count--;
	return data;
}

void show(Queue *queue) {
	if (queue->count == 0) {
		printf("No data in Queue !! \n");
		return -INF;
	}

	Node* cur = queue->front;

	printf("Front Of Queue \n");
	while (cur != NULL) {
		printf("%d \n", cur->data);
		cur = cur->next;
	}
	printf("Rear Of Queue \n");
}

int main() {
	Queue queue;
	queue.count = 0;
	queue.front = NULL;
	queue.rear = NULL;

	push(&queue, 2);
	push(&queue, 1);
	push(&queue, 5);
	push(&queue, 7);
	push(&queue, 6);
	pop(&queue);
	push(&queue, 8);
	pop(&queue);
	push(&queue, 3);
	show(&queue);
	system("pause");
	return 0;
}

 

be the happy Gosu.

woojja ))*

반응형
LIST

'ETC > C, C++' 카테고리의 다른 글

[C, C++] Queue in Array, Linked List  (0) 2021.10.20
[C, C++] Stack in Array, Lined List  (0) 2021.10.20
[C, C++] Sorted Doubly Linked List  (0) 2021.10.20
Posted by woojja
TAG C, Queue

댓글을 달아 주세요

 

1. Stack in Array

#include <stdio.h>
#include <stdlib.h> 

#define SIZE 10000
#define INF		99999

int stack[SIZE];
int top = -1;

void push(int data) {
	if (top == SIZE - 1) {
		printf("Stack Overflow !!");
		return;
	}
	stack[++top] = data;
}

int pop() {
	if (top == -1) {
		printf("Stack Underflow !!");
		return -INF;
	}

	return stack[top--];
}

void show() {
	printf("Top Of Stack \n");
	for (int i = top; i >= 0; i--) {
		printf("%d \n", stack[i]);
	}
	printf("Bottom Of Stack \n");
}


int main() {							  
	push(2);
	push(1);
	push(5);
	push(7);
	push(6);
	pop();
	push(8);
	pop();
	push(3);
	show();
	system("pause");
	return 0;
}

2. Stack in Lined List

#include <stdio.h>
#include <stdlib.h>	 
#define INF		99999

typedef struct {
	int data;
	struct Node* next;
} Node;

typedef struct {
	struct Node *top;
} Stack;
					   
void push(Stack *stack, int data) {
	Node* node = (Node*)malloc(sizeof(Node));	

	node->data = data;
	node->next = stack->top;

	stack->top = node;
}

int pop(Stack *stack) {
	if (stack->top == NULL) {
		printf("Stack Underflow !!\n");
		return -INF;
	}

	Node* top = (Node*)malloc(sizeof(Node));
	top = stack->top;
	stack->top = top->next;
	int data = top->data;
	free(top);
	return data;
	
}

void show(Stack *stack) {
	Node* cur = stack->top;

	printf("Top Of Stack \n");
	while (cur != NULL) {
		printf("%d \n", cur->data);
		cur = cur->next;
	}
	printf("Bottom Of Stack \n");
}

int main() {
	Stack stack;
	stack.top = NULL;

	push(&stack, 2);
	push(&stack, 1);
	push(&stack, 5);
	push(&stack, 7);
	push(&stack, 6);
	pop(&stack);
	push(&stack, 8);
	pop(&stack);
	push(&stack, 3);
	show(&stack);
	system("pause");
	return 0;
}

be the happy Gosu.

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형
LIST

'ETC > C, C++' 카테고리의 다른 글

[C, C++] Queue in Array, Linked List  (0) 2021.10.20
[C, C++] Stack in Array, Lined List  (0) 2021.10.20
[C, C++] Sorted Doubly Linked List  (0) 2021.10.20
Posted by woojja
TAG C, stack

댓글을 달아 주세요

#include <stdio.h>
#include <stdlib.h> 

typedef struct {
	int data;
	struct Node *prev;
	struct Node *next;
} Node;

Node *head, *tail;

void insert(int data) {
	Node* node = (Node*)malloc(sizeof(Node));
	node->data = data;

	Node* cur;
	cur = head->next;
	while (cur->data < data && cur != tail) {
		cur = cur->next;
	}

	Node* prev = cur->prev;

	prev->next = node;
	node->prev = prev;

	cur->prev = node;
	node->next = cur;
}

void removeFront() {
	Node* node = head->next;
	head->next = node->next;

	Node* next = node->next;
	next->prev = head;

	free(node);
}

void show() {
	Node* cur = head->next;
	while (cur != tail) {
		printf("%d \n", cur->data);
		cur = cur->next;
	}
}

int main(void) {
	head = (Node*)malloc(sizeof(Node));
	tail = (Node*)malloc(sizeof(Node));
	head->prev = head;
	head->next = tail;
	tail->prev = head;
	tail->next = tail;

	insert(4);
	insert(9);
	insert(3);
	insert(1);
	insert(8);
	insert(7);
	insert(6);
	insert(2);
	removeFront();
	show();

	system("pause");
	return 0;
}

 

be the happy Gosu.

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형
LIST

'ETC > C, C++' 카테고리의 다른 글

[C, C++] Queue in Array, Linked List  (0) 2021.10.20
[C, C++] Stack in Array, Lined List  (0) 2021.10.20
[C, C++] Sorted Doubly Linked List  (0) 2021.10.20
Posted by woojja

댓글을 달아 주세요

There is a code snippet in the query that I don't understand, but i write them down. ^^;

SELECT TO_CHAR(TO_DATE(ROWNUM+2454832, 'J'), 'YYYYMMDD') AAA
FROM (
    SELECT LEVEL M FROM DUAL
    CONNECT BY LEVEL <= 2556
)
ORDER BY AAA

Result :

 

DateFormat 'J' Option is

Julian day; the number of days since January 1, 4712 BC. Number specified with J must be integers.

https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924

 

Format Models

The total length of a datetime format model cannot exceed 22 characters. The default datetime formats are specified either explicitly with the initialization parameter NLS_DATE_FORMAT or implicitly with the initialization parameter NLS_TERRITORY. You can c

docs.oracle.com

 

What is the principle of this snippet?

SELECT LEVEL M FROM DUAL
CONNECT BY LEVEL <= 2556


I can guess why, but I don't understand the principle.

Is there anyone who can teach me? ^^;

 

There is a saying in Korea.

If you don't understand, calm down and read(memorize) it.

^^;

 

be the happy Gosu.

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 

반응형
LIST
Posted by woojja

댓글을 달아 주세요

2021. 10. 6. 15:47

GPS Location 관련 자료를 찾다가 알게된 Site 입니다.

https://drfone.wondershare.net/

 

[Official]Dr.Fone - Mobile Solutions for All iOS & Android Users

"Rest assured as Dr.Fone enjoys the trust of millions of users worldwide and it has won critical acclaim from reputed media outlets such as PC World, Forbes, CNET, etc. "

drfone.wondershare.net

 

해당 사이트의 아래 페이지를 보니 집에 가만히 앉아서도 GPS 관련 Game 이나 App 을 사용할 수 있겠네요. ^^

https://drfone.wondershare.net/ad/ios-virtual-location.html?gclid=EAIaIQobChMI3srRnLyy8wIVArqWCh0QtgA0EAMYASAAEgJy3fD_BwE 

 

[Official]Dr.Fone - Virtual Location: Spoof/Change Location on iPhone in 1 Click

 

drfone.wondershare.net

 

행복한 고수되십시오.

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형
LIST

'ETC' 카테고리의 다른 글

[ETC] Virtual Location  (0) 2021.10.06
[ETC] Paypal 개인결제 링크 만들기  (0) 2021.09.28
[ETC] VisualStudio Error  (0) 2020.04.16
[ETC] File Signatures  (0) 2017.10.12
[ETC] YouTube image Size  (0) 2016.04.06
[ETC] LG UPlus 결제모듈 연동을 위한 서버설정.  (0) 2014.10.08
Posted by woojja

댓글을 달아 주세요

이전버튼 1 이전버튼
반응형