Comparison Counting Sort

Hi cplusplus forum,
could someone help me build this into a compliling C++ code please? I would then like to build some pretty graphics for it too.

for i = 0 to n - 1 do
Count[i] = 0
for i = 0 to n - 2 do
for j = i + 1 to n - 1 do
if A[i] < A[j]
Count[j] = Count[j] + 1
else Count[i] = Count[i] + 1
for i = 0 to n - 1 do
S[Count[i]] = A[i]

// Algorithm ComparisonCountingSort (A0..n-1), S[0..n-1])
// Sort list: 60, 35, 81, 98, 14, 47.
//Sorts an array by counting for each of its elements, the number of smaller elements and then
// uses this information to put the element in its appropriate position in the sorted array.
closed account (o3hC5Di1)
Hi there,

How about you give this your best shot and get back to us when you run into trouble - and then we'll go from there? :)

All the best,
NwN
Topic archived. No new replies allowed.