# Include <cstdlib> # include <iostream> # include <vector> using namespace STD; void input (vector <int> & V) {int data; while (CIN> data) {v. push_back (data) ;}} void print (const vector <int> & V) {for (vector <int>: const_iterator iter = v. begin (); iter! = V. end (); ITER ++) cout <* ITER <"; cout <Endl;} void countsort (vector <int> & V) {int K = 20; // assume that the input number ranges from 0 to 20. Vector <int> res (v. size (); vector <int> VC (k + 1); For (vector <int>: iterator it = v. begin (); it! = V. end (); It ++) {VC [* It] ++;} For (Int J = 1; j <= K; j ++) {VC [J] + = VC [J-1];} For (Int J = v. size ()-1; j> = 0; j --) {res [VC [V [J]-1] = V [J]; // understand this sentence. starting from the last element, put VC [V [J] --;} print (RES) ;}int main (INT argc, char * argv []) {vector <int> V; input (V); countsort (V); System ("pause"); Return exit_success ;}