码迷,mamicode.com
首页 > 其他好文 > 详细

离散化

时间:2018-11-28 12:42:02      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:lower   strong   ++i   unique   for   cout   离散化   sort   uniq   

(说明后补)

cin >> n;
for (int i = 1;i <= n; ++i) {
cin >> B[i];
C[i] = B[i];
}
sort(C+1,C+n+1);
int m = unique(C+1,C+n+1) - C-1;


for (int i = 1;i <= n; ++i) {
B[i] = lower_bound(C+1,C+m+1,B[i]) - C;
}
for (int i = 1;i <= n; ++i) {
cout << C[B[i]] << " ";
}
cout << endl;

离散化

标签:lower   strong   ++i   unique   for   cout   离散化   sort   uniq   

原文地址:https://www.cnblogs.com/frankscode/p/10030008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!