标签:等于 logs cout name level 编辑 思想 计数 bsp
1 #include <iostream> 2 using namespace std; 3 const int MAXN = 100000; 4 const int k = 1000; // range 5 int a[MAXN], c[MAXN], ranked[MAXN]; 6 7 int main() { 8 int n; 9 cin >> n; 10 for (int i = 0; i < n; ++i) { 11 cin >> a[i]; 12 ++c[a[i]]; 13 } 14 for (int i = 1; i < k; ++i) 15 c[i] += c[i-1]; 16 for (int i = n-1; i >= 0; --i) 17 ranked[--c[a[i]]] = a[i];//如果是i表达的是原数标号,a[i]就是排序后的正确序列 18 for (int i = 0; i < n; ++i) 19 cout << ranked[i] << endl; 20 return 0; 21 }
标签:等于 logs cout name level 编辑 思想 计数 bsp
原文地址:http://www.cnblogs.com/yhyl/p/6591749.html