제발 도와좀주세요..ㅠㅠ
찬솔
질문 제목 : 주석달기주석을 달다가 막혀서..막힌부분주석다는것좀 도와주세요ㅜㅜ..질문 내용 :
//* 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;
}
}
| 번호 | 제 목 | 글쓴이 | 날짜 |
|---|---|---|---|
| 2752085 | 문자열을 랜덤하게 출력해서 대체,삽입,삭제 횟수를 각가 표시하고 그걸 표 형태로 출력 | 슬아s | 2026-10-20 |
| 2752056 | 포인터 && 배열 질문요~ (2) | 해찬나래 | 2026-10-20 |
| 2752031 | x^n 구하는 코드 짜봤는데 값이 틀려요 ㅠㅠ | 세실 | 2026-10-20 |
| 2752000 | 나 정말 미치겠어요..ㅠㅜ (4) | 다이 | 2026-10-20 |
| 2751978 | 문자열 질문이요.. | 초시계 | 2026-10-19 |
| 2751945 | 숫자 맞추는 프로그램이요 ㅠㅠ (1) | 동은 | 2026-10-19 |
| 2751917 | C언어 이중 연결 관련 질문합니다. | 유우 | 2026-10-19 |
| 2751888 | return의 정확한 의미좀 알려주세요 (3) | 올해1살 | 2026-10-19 |
| 2751857 | 포인터 배열 (2) | 터큰 | 2026-10-18 |
| 2751831 | 연산자? 질문입니다 (2) | 진주 | 2026-10-18 |
| 2751800 | C언어 기초질문입니다.. (3) | 핫블랙 | 2026-10-18 |
| 2751739 | 파일 출력을 구조체로 받을 때, 파일의 끝을 판별하는 방법을 알려주세요. (2) | 얼 | 2026-10-17 |
| 2751715 | unresolved external symbol 에러... | 이룩 | 2026-10-17 |
| 2751686 | 변수 설정에 관한 질문입니다. | 꽃달 | 2026-10-17 |
| 2751655 | 자료구조 연습문제 | 한무릎 | 2026-10-17 |
| 2751631 | gets 함수 질문이요. (4) | 해늘 | 2026-10-16 |
| 2751553 | 퀵정렬 소스인데 주석좀 달아주세요 (1) | 싴흐한세여니 | 2026-10-16 |
| 2751528 | 저기 이거하는법좀 질문.. (2) | 가람슬기 | 2026-10-15 |
| 2751445 | 도저히 풀 수가 없네요.... (2) | 신당 | 2026-10-15 |
| 2751412 | 어제부터 계속 해도.........안되는.... (1) | 족장 | 2026-10-14 |
