원형큐인데 좀 봐주세요~
진이
제가 작성한건데요 경고가 뜨면서 안되네요~ 빨간색으로 표시해났습니다~
실행 메뉴는 총 4개
① 입력 (push) : 데이터 삽입
② 삭제 (pop) : 데이터 삭제
③ 보기 (queue의 마지막 인덱스에서 막힘없이 처음 인덱스로 구현되는 모습을 보여주면 댐)
④ 종료 (프로그램 종료)
입력시에 대한 사항 : 메뉴 입력시에 정의 되어 있지 않는 데이터에 대한 오류 검출 기능 추가 요망
보기 에 대한 메뉴 구현은 아래의 규칙을 기본적으로 구현 할것
1) 메뉴 선택시에 하나씩 보여주며, 다음것을 계속 보게 하여, 한바퀴를 돌아서 다시 보게 되게 구현질문 내용 :
#includestdio.h
#includemalloc.h
typedef struct
{
char name[10];
int id;
char number[20];
}element;
typedef struct
{
element item;
struct queuenode *link;
}queuenode;
typedef struct
{
queuenode *front, *rear;
}queuelink;
int count=0;
void error(char *mess)
{
fprintf(stderr,%s\n,mess);
}
void init(queuelink *q)
{
q-front=q-rear=null;
}
int is_empty(queuelink *q)
{
return (q-front==null);
}
void enqueue(queuelink *q,element item)
{
queuenode *temp=(queuenode*)malloc(sizeof(queuenode));
if(temp=null)
error(할당에러);
else if(count9)
error(10초과됐다);
else{
temp-item=item;
temp-link=null;
if(is_empty(q)){
q-front=temp;
q-rear=temp;
count++;
}
else{
q-rear-link=temp; //queuenode*와queuenode*사이의 형식이 호환되지 안된다고 하네요~
q-rear=temp;
count++;
}
}
}
element dequeue(queuelink *q)
{
queuenode *temp=q-front;
element item;
if(is_empty(q))
error(큐가 비어져있습니다);
else{
item=temp-item;
q-front=q-front-link; //queuenode*와queuenode*사이의 형식이 호환되지 안된다고 하네요~
if(q-front==null)
q-rear=null;
count--;
free(temp);
return item;
}
}
int main()
{
queuelink tenq;
int num;
element a;init(&tenq);
while(1)
{
printf(1.입력\n);
printf(2.삭제\n);
printf(3.보기\n);
printf(4.종료\n);
printf(메뉴선택\n);
scanf(%d, &num);
if(num==4)
break;
else if(num==1){
printf(이름 : );
scanf(%s,&a.name);
printf(학번 : );
scanf(%d,&a.id);
printf(전화번호 : );
scanf(%s,&a.number);
enqueue(&tenq,a);
}
else if(num==2){
dequeue(&tenq);
}
else if(num==3){
while(count0){
printf(----------------------------);
printf(%s,tenq.front-item.name);
printf(%d,tenq.front-item.id);
printf(%s,tenq.front-item.number);
printf(----------------------------);
tenq.front=tenq.front-link; //queuenode*와queuenode*사이의 형식이 호환되지 안된다고 하네요~
count--;
}
}
else
printf(잘못입력했습니다);
}
return 0;
}
-
발랄한그1녀
typedef struct == typedef struct _queuenode
{
element item;
struct queuenode *link; == struct _queuenode *link;
}queuenode;
void enqueue(queuelink *q,element item)
{
queuenode *temp=(queuenode*)malloc(sizeof(queuenode));
if(temp=NULL) == if(temp
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2656991 | 멀티쓰레드 예제 하나만요. (3) | 키움 | 2024-06-02 |
2656966 | 문자열 상수 저장메모리 (5) | 은별 | 2024-06-02 |
2656912 | 퀵정렬인데 급해요 ㅠㅠ | 큰돌찬 | 2024-06-02 |
2656767 | 초보입니다.. (1) | 플랜 | 2024-05-31 |
2656744 | 재귀함수 공부하다 이해가 안가서 질문드려요 (10) | PinkPearl | 2024-05-31 |
2656717 | 10진수를 2진수로 바꾸는 프로그램인데요 (3) | 감춰왔던 | 2024-05-31 |
2656686 | 포인터의 메모리값에 문자열넣기가 원래 안되나요..? | 심플이 | 2024-05-31 |
2656658 | 두가지 질문...(요약하기가 어렵내요... 죄송합니다..) | 한봄찬 | 2024-05-30 |
2656583 | 배열에 주소값대입 왜!!!!!!!!!!! (6) | 갅쥐누뉨 | 2024-05-30 |
2656555 | C언어 인데요 EOF에 대해서에여 알고리즘.. | 루라 | 2024-05-29 |
2656531 | 과제가왔는데 문제이해조차못하겠네요.. (2) | 다온 | 2024-05-29 |
2656502 | 비트 연산자 부분 질문드려요... (1) | 진주 | 2024-05-29 |
2656474 | c언어 왕초보인데요.. (4) | 예님 | 2024-05-29 |
2656444 | switch 문 대신에 다른 것을 사용하는 방법 (1) | 맺음새 | 2024-05-28 |
2656365 | for문하나로 1부터 100까지 5의배수 아닌 수들의 합을 구하는 프로그램 질문입니다. (7) | 똘끼 | 2024-05-28 |
2656309 | 구조체를 배열로 여러개만든뒤 함수에서 사용하는법? | 눈내리던날 | 2024-05-27 |
2656280 | c언어 프로그램 틀좀 잡아주실수 있는분.. (2) | 별하 | 2024-05-27 |
2656247 | 질문이 있는데요... | 시원 | 2024-05-27 |
2656218 | 함수 반환하는거 질문 ㅠ | 스릉흔다 | 2024-05-26 |
2656166 | 갑자기 증가하거나 감소하는 부분 처리. (2) | 마디 | 2024-05-26 |