제발 도와좀주세요..ㅠㅠ
펴라
질문 제목 : 주석달기주석을 달다가 막혀서..막힌부분주석다는것좀 도와주세요ㅜㅜ..질문 내용 :
//* is_empty 함수부분 *//
int is_empty(struct node *sorted_list)
{
int n1;
if (head == null){ //* head가 null값이면 empty*//
n1 = 0;
printf(\n\n자료가 비어있습니다! \n\n); //* 공백 리스트일경우 메세지 출력 *//
}
else {
n1 = 1;
}
return n1;
}
//* add 함수부분 *//
struct node *add(struct node *sorted_list, int item)
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node)); //* node의 동적메모리 할당 *//
newnode-data = item; //* 입력받은 item이 newnode의 data가된다*//
if(head==null){ //* head가 비어있으면 head에 newnode 생성 *//
head=newnode;
newnode-next=null; //* newnode의 next 는 null로 초기화 *//
}
else { //* head가 null이 아닌경우 *//
newnode-next = sorted_list-next;
sorted_list-next = newnode; //* 이미정렬되어있는 리스트에 new node를 이어붙인다 *//
}
printf(\n[%d] 가 추가 되었습니다.\n,newnode-data); //* add 추가성공 메세지 출력 *//
sort(); //* 입력받은 정수들을 정렬상태로 저장 *//
return (newnode);
}
//* delete 함수부분 *//
struct node *delete(struct node *sorted_list, int item)
{
struct node *p, *q, *r;
while((is_in_list(sorted_list, item)) ==1) { //* 리스트에 삭제하고자 하는 자료가 있는지 확인한다 *//
if((is_in_list(sorted_list, item)) == 1)
{
p=q=head; //* 포인터 p 와 q를 head 로 초기화 *//
q=q-next;
do
{
if(p-data==item)
{
q=p-next;
head=q;
free(p);
break;
}
else if(q-data==item)
{
r=q-next;
p-next=q-next;
free(q);
break;
}
p=p-next;
q=q-next;
}while(1);
printf(\n [%d]가 리스트에서 삭제되었습니다.\n, item);
}
}
return sorted_list;
}
//* display 함수부분 *//
struct node *display(struct node *sorted_list)
{
temp = head;
while (temp != null)
{
printf(\n [%d] \n , temp-data);
temp = temp-next;
}
return(temp);
}
//* is_in_list 함수부분 *//
int is_in_list(struct node *sorted_list, int item)
{
int n2;
temp = head;
while (temp != null)
{
if (temp-data == item)
{
n2 = 1;
printf(\n입력하신 자료가 리스트에 있습니다. \n);
break;
}
n2 = 0;
temp = temp-next;
}
if (n2 == 0)
{
printf(\n입력하신 자료가 리스트에 없습니다. \n);
}
return n2;
}
//* get_length 함수부분 *//
int get_length(struct node *sorted_list)
{
temp = head;
length=0;
while (temp != null)
{
temp = temp-next;
length++;
}
return length;
}
//* clear 함수부분 *//
void clear(struct node *sorted_list)
{
head=null;
free(head);
}
//* 정렬을위한 함수 *//
void sort()
{
int temp;
struct node *str1;
struct node *str2;
str1 = head;
str2 = head-next;
while(str1 != null){
while(str2 != null) {
if(str1-data str2-data ){
temp = str1-data;
str1-data = str2-data;
str2-data = temp;
}
str2 = str2-next;
}
str2 = str1-next;
str1 = str1-next;
}
}