-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
65 lines (47 loc) · 1.3 KB
/
main.cpp
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
#include <stdio.h>
#include "Stack.h"
void prnMenu(){
cout<<"*******************************************"<<endl;
cout<<"* 1. 삽입 2. 삭제 3. 출력 4. 종료 *"<<endl;
cout<<"*******************************************"<<endl;
cout<<endl;
cout<<"원하시는 메뉴를 골라주세요: ";
}
int main(){
int mode, selectNumber, tmpItem;
LinkedList<int> *p;
bool flag = false;
cout<<"자료구조 선택(1: Stack, Other: Linked List): ";
cin>>mode;
if(mode == 1)
p = new Stack<int>(); // 정수를 저장하는 스택
else
p = new LinkedList<int>();
do{
prnMenu();
cin>>selectNumber;
switch(selectNumber){
case 1:
cout<<"원하시는 값을 입력해주세요: ";
cin>>tmpItem; p->Insert(tmpItem);
cout<<tmpItem<<"가 삽입되었습니다."<<endl;
break;
case 2:
if(p->Delete(tmpItem)==true)
cout<<tmpItem<<"가 삭제되었습니다."<<endl;
else cout<<"비어있습니다. 삭제 실패"<<endl;
break;
case 3:
cout<<"크기: "<<p->GetSize()<<endl;
p->Print();
break;
case 4:
flag = true; break;
default:
cout<<"잘못 입력하셨습니다."<<endl;
break;
}
if(flag) break;
} while(1);
return 0;
}