3168 Sort ZOJ7

#include<stdio.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;

int mp[280];
bool cmp(char a,char b)
{
	return mp[a]<mp[b];
}

int main()
{
	char str[1010];
	mp['Z']=-4; mp['O']=-3;
	mp['J']=-2; mp['7']=-1;    

    while(cin>>str)
	{
	   int len=strlen(str);
	   stable_sort (str,str+len,cmp);
	   printf("%s\n",str);
	}
	return 0;
}

你可能感兴趣的:(3168 Sort ZOJ7)