这题好恶心- -规律找了好久
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int num;
while(cin >> num && num)
{
int nums[50],Queue[50];
char flag;
memset(Queue,0,sizeof(Queue));
cin >> flag;
for(int m = 0;m<num;m++)
cin >> nums[m];
if(flag == 'P')
{
for(int m = num - 1;m>=0;m--)
{
int zero = 0;
for(int u = m - 1;u>=0;u--)
{
if(nums[m] < nums[u])
zero++;
}
Queue[nums[m]-1] = zero;
}
}
else
{
for(int m = 0;m<num;m++)
{
int zero = 0;
for(int u = 0;u<num;u++)
{
if(Queue[u] == 0)
zero++;
if(zero == nums[m]+1)
{
Queue[u] = m + 1;
break;
}
}
}
}
for(int m = 0;m<num;m++)
{
cout << Queue[m];
if(m != num - 1)
cout << ' ';
else cout << endl;
}
}
return 0;
}