글은 제목 잘못적었는데 비번을 잘못설정했는지 수정이 안돼서 다시올림



struct set

{

int data;

struct set* link;

};

typedef struct set set;


set* alloc()

{

set *tmp;

tmp=(set*)malloc(sizeof(struct set));

return tmp;

}


int enq(set **head,int count,int data)

{

if(count>=8)

{

printf("que is full.\n");

return 0;

}

if(*head==0)

{

*head=alloc();


printf("input data : ");

scanf_s("%d",&data);


(*head)->>

(*head)->link=0;

count++;

return count;

}

else

{

count=enq(&(*head)->link,count,data);

return count;

}

}



int deq(set **head,int count,int data)

{

if(*head==0)

{

puts("que is empty\n");

return count;

}

else

{

*head=(*head)->link;

--count;

return count;

}

}


void list(set **head,int count,int data)

{

if(*head==0)

{

puts("que is empty.\n");

return;

}

else

{

set *tmp;

tmp=*head;

while(1)

{

printf("%d ",(*head)->data);

if((*head)->link==0)

{

printf("end of quue\n");

printf("count of arr is %d\n",count);

break;

}

else

{

*head=(*head)->link;

}

}

*head=tmp;

return;

}

}

void main()

{

int num,>

set *head=0;


while(1)

{

printf("1.Enque number\n2.Deque number\n3.show list\n > ");

scanf_s("%d",&num);


switch(num)

{

case 1:count=enq(&head,count,data); printf("input complete.\n"); system("pause"); break;

case 2:count=deq(&head,count,data); printf("delete complete.\n"); system("pause"); break;

case 3:list(&head,count,data); system("pause"); break;

}

system("cls");

}

return;

}



제대로 작동은 되는데 내가 제대로 한건지 잘모르겠다.. 해설보니까 '테일'이라고 꼬리쪽도 달아주던데.. 난 안썻거든. 야매로한건가 ㅠㅠ


지적질좀 해줘. 가독성 개병신인건 미안. 


(카운트 있는건 문제에서 큐 길이를 8까지만으로 제한하라고 하더라고. 그래서 달아놓은거.)