#include<stdio.h>
#include<stdlib.h>
#define MAX 300000
typedef struct{
int data;
struct node * link;
}node;
node * get_node(){
node *tmp =(node *)malloc(sizeof(node));
tmp->data = 0;
tmp->link = NULL;
return tmp;
}
void pl(node *start){
node *tmp;
printf("%d n",start->data);
if(start->link==NULL)return ;
tmp = start->link;
while(1){
printf("%d n",tmp->data);
if(tmp->link == NULL)break;
tmp = tmp->link;
}
}
void insertQ(int data,node **front,node **rear){
node* tmp = get_node();
tmp->data =data;
if( * rear != NULL)
(*rear)->link = tmp;
(*rear) = tmp;
if(*front==NULL)
*front= tmp;
}
int deleteQ(node **front,node **rear){
node tmp;
tmp = **front;
if((*front) !=NULL){
free(*front);
*front = tmp.link;
}else{
printf("언더플로우에러...!!n");
return 1<<31;
}
return tmp.data;
}
int main(int* argc,char* argv[]){
node *front=NULL,*rear=NULL;
insertQ(33,&front,&rear);
insertQ(24,&front,&rear);
insertQ(34,&front,&rear);
pl(front);
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
{
int i;
for(i=0;i<10000000;i++){
insertQ(34,&front,&rear);
deleteQ(&front,&rear);
}
scanf("%d",&i);
}
return 1;
}



#include<stdio.h>
#include<stdlib.h>
#define MAX 300000
#define DEBUG 0
typedef struct{
int data;
struct node * link;
}node;
node * get_node(){
node *tmp =(node *)malloc(sizeof(node));
tmp->data = 0;
tmp->link = NULL;
return tmp;
}
void pl(node *start){
node *tmp;
printf("%d n",start->data);
if(start->link==NULL)return ;
tmp = start->link;
while(1){
printf("%d n",tmp->data);
if(tmp->link == NULL)break;
tmp = tmp->link;
}
}
void insertQ(int data,node **front,node **rear){
node* tmp = get_node();
tmp->data =data;
if( * rear != NULL)
(*rear)->link = tmp;
(*rear) = tmp;
if(*front==NULL)
*front= tmp;
}
int deleteQ(node **front,node **rear){
node tmp;
if((*front) ==NULL){
printf("언더플로우에러...!!n");
return 1<<31;
}
tmp = **front;
free(*front);
*front = tmp.link;
if(tmp.link ==NULL){
*rear=NULL;
}
return tmp.data;
}
int main(int* argc,char* argv[]){
node *front=NULL,*rear=NULL;
printf("-----%d %dn",front,rear);
insertQ(33,&front,&rear);
insertQ(24,&front,&rear);
insertQ(34,&front,&rear);
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("%d n",deleteQ(&front,&rear));
printf("-----%d %dn",front,rear);
#if DEBUG
{
int i;
for(i=0;i<10000000;i++){
insertQ(34,&front,&rear);
deleteQ(&front,&rear);
}
scanf("%d",&i);
}
#endif
return 1;
}