가천대 2020 인공지능소프트웨어학과_자료구조 HOMEWORK1_ (1.linked list 스택 구현, 2. 2개의 큐로 스택 구현 3. 2개의 스택으로 큐 구현)
- 최초 등록일
- 2020.04.17
- 최종 저작일
- 2020.04
- 17페이지/ MS 워드
- 가격 2,000원
소개글
"가천대 2020 인공지능소프트웨어학과_자료구조 HOMEWORK1_ (1.linked list 스택 구현, 2. 2개의 큐로 스택 구현 3. 2개의 스택으로 큐 구현)"에 대한 내용입니다.
목차
1. PHW 1-1
2. PHW 1-2
3. PHW 1-3
4. PHW 1-4
본문내용
PHW 1-1
Implement and Test a Stack Program, Using a Singly Linked List.
for the same 4 functions (of Lab 1-1).
Due: March 13, Midnight (e-class)
#include <stdio.h>
#include <stdlib.h>
//Stack program using a singly linked list.
typedef struct node {
int data;
struct node*next;
}Node;
Node*head = NULL;
//------------ main -------------//
int main() {
void push(int);
int pop();
void showArray();
void ListStack();
void ClearStack();
int stack_full();
int stack_empty();
Node*Getnode();
int select = 0, value = 0, run = 1, tmp = 0;
while (run) {
puts("========== stack program ============");
puts("select the menu > 1.push 2.pop 3.end : ");
scanf_s("%d", &select);
switch (select) {
case 1:
printf("Type the data to push : ");
scanf_s("%d", &value);
if (stack_full()) {
puts("stack is full");
break;
}
push(value);
ListStack();
break;
case 2:
if (!stack_empty()) {
printf("removed data: %d\n", pop());
}
else {
puts("stack is empty");
}
break;
참고 자료
없음