원형큐인데 좀 봐주세요~
진이
제가 작성한건데요 경고가 뜨면서 안되네요~ 빨간색으로 표시해났습니다~
실행 메뉴는 총 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
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |
2691393 | UNIX 시스템을 사용하려면 어떤 프로그램이 좋을까요? (5) | 든솔 | 2025-04-13 |