#include <stdio.h>
#include <stdlib.h>
#define MAXQSIZE 100
typedef struct {
char *base;
int front;
int rear;
}SqQueue;
void InitQueue(SqQueue &Q){
char c;
int n;
Q.base = (char *)malloc(MAXQSIZE * sizeof(char));
if(!Q.base )
return ;
Q.front = Q.rear = 0;
scanf("%d",&n);
if(n >= MAXQSIZE || n <= 0)
return ;
while(n --){
c = getchar();
Q.base [Q.rear ] = c;
Q.rear = (Q.rear + 1) % MAXQSIZE;
}
}
void Merge(SqQueue Qman, SqQueue Qwoman, int n){
int i = Qman.front , j = Qwoman.front, index, ans = 0;
while(n --){
index = Qman.rear < Qwoman.rear ? Qman.rear : Qwoman.rear;
printf("\n=====%d=====\n",++ans);
while(index --){
printf("%c<-->%c\n",Qman.base [i], Qwoman.base [j]);
i = (i + 1) % Qman.rear;
j = (j + 1) % Qwoman.rear;
}
}
}
int main(){
SqQueue Qman,Qwoman;
int n;
InitQueue(Qman);
InitQueue(Qwoman);
scanf("%d",&n);
Merge(Qman,Qwoman,n);
return 0;
}
舞会配对
最新推荐文章于 2021-11-12 17:50:40 发布