diff --git a/Radix Sort.cpp b/Radix Sort.cpp new file mode 100644 index 000000000..eb3f12a57 --- /dev/null +++ b/Radix Sort.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +using namespace std; +void radixsort(int a[],int n){ + int count[10]; + int output[n]; + memset(output,0,sizeof(output)); + memset(count,0,sizeof(count)); + int max = 0; + for (int i = 0; i < n; ++i) + { + if (a[i]>max) + { + max = a[i]; + } + } + int maxdigits = 0; + while(max){ + maxdigits++; + max/=10; + } + for(int j=0;j