|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<iostream>
using namespace std;
class CirQueue
{
private:
int data[100];
int front,rear;
public:
CirQueue()
{
front=rear=0;
}
void EnQueue(int x,int n)
{
rear=(rear+1)%n;
data[rear]=x;
}
void GetQueue(int n)
{
front=(front+1)%n;
if(n%2==0)
{
while(n==0)
{
while(data[front]%2==1)
{
front = (front+1)%n;
}
cout<<"man"<<data[front]<<"-";
n--;
while(data[front]%2==0)
{
front = (front +1)%n;
}
cout<<"woman"<<data[front];
n--;
continue;
}
cout<<endl;
}
else
{
while(n==1)
{
while(data[front]%2==1)
{
front = (front+1)%n;
}
cout<<"man"<<data[front]<<"-";
n--;
while(data[front]%2==0)
{
front = (front +1)%n;
}
cout<<"woman"<<data[front];
n--;
cout<<endl;
}
cout<<endl;
}
}
};
int main()
{
int n;
int a[100];
while(cin>>n)
{
CirQueue Q;
for(int i=0;i<n;i++)
{
cin>>a[i];
Q.EnQueue(a[i],n);
}
Q.GetQueue(n);
}
return 0;
} |
|