关于离散化,

推荐几篇博客

http://www.matrix67.com/blog/archives/108

http://blog.csdn.net/doyouseeman/article/details/51154142

#include<cstdio>
#include<algorithm>
using namespace std;
int a[10001],date[10001],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]),date[i]=a[i];
	sort(date+1,date+n+1);
	int num=unique(date+1,date+n+1)-date-1;
	for(int i=1;i<=n;i++)	a[i]=lower_bound(date+1,date+num+1,a[i])-date;
	for(int i=1;i<=n;i++)	printf("%d ",date[a[i]]);	 
	return 0;
}