1111

10185101228 edited 5 年,9 月前

include

include

struct CirQueue{
char a[105];
int front;
int count;
int rear;
}queue;
void append(struct CirQueue q,char n){
if(q->rear==99)
q->rear=0;
else
q->rear++;
q->count++;
q->a[q->rear]=n;
}
void serve(struct CirQueue
q){
q->count–;
if(q->front==99)
q->front=0;
else q->front++;
}
int retrieve(struct CirQueue a,int front){
return a->a[*front];
}
int main()
{
queue.front=0;
queue.rear=-1;
queue.count=0;
char n;
int i,j,k;
int T;
int len1,len2;
scanf(“%d”,&T);
while(T–){
scanf(“%c”,&n);
while(n!=’\n’){
append(&queue,n);
n=getchar();
}
while(1){
if(queue.a[queue.front]==’:’){
i=queue.front;
j=queue.count-queue.front-1;
break;
}
serve(&queue);
}
if(i>j)
printf(“L”);
if(i<j)
printf(“R”);
if(i=j){
printf(“D”);
}
}
return 0;
}

Comments