#include
#include
#include
#include
#include
#include"01.h"
boolean list_full() { // 다 찼는지 검사
if (size == MaxSize) // 사이즈가 맥스사이즈면 다 찬것
return true;
else
return false;
}
boolean list_empty() { // 비어있는지 검사
if (!size) // size == 0 이면 true
return true;
else
return false;
}
void list_show() {
if (list_empty()) { // 리스트가 비어있으면
printf("\nList is Empty !!! \n"); // 리스트가 비어있음.
}
else {
printf("\n"); //그렇지 않으면 size까지 출력
for (int i = 0; i <= size; i++)
printf("%c ", List[i]);
}
}
void list_insert(Element e) {
if (list_full()) // 리스트가 꽉 차있는지 검사
printf("\nList is full !!! \n"); //꽉 차 있으면 출력
else { // 그렇지 않으면 리스트의 끝에 삽입 , size +1
List[size] = e;
size++;
}
}
void list_delete(Element e) {
int position = -1; // 지울 곳을 나타내는 포지션 변수 초기값 -1
for (int i = 0; i < size; i++) { // size까지 i를 돌리면서 e가 있는지 검사
if (e == List[i]) {
position = i; // e가 있다면 포지션 값
break;
}
}
if (position == -1 || list_empty()) // 포지션 변수가 초기값이거나 비어있다면
printf("\nData does not exist !!! \n"); // 데이터가 존재하지 않음.
else {
for (int i = position; i < size; i++) { // 포지션 변수부터 size까지
List[i] = List[i + 1]; // 현재 리스트 값에 +1 값을 저장
}
size--; // size -1
}
}