Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i=1; i<=n; i++)
- {
- double c = sqrt(i)/sqrt(n);
- b[i]=c;
- cout<<c<<endl;
- }
- void bucketSort(vector<double> &arr, int n)
- {
- // 1) Create n empty buckets
- vector<double> b[n];
- //fnid the ring and set bucket
- for (int i=1; i<=n; i++)
- {
- double c = sqrt(i)/sqrt(n);
- b[i]=c;
- cout<<c<<endl;
- }
- // 2) Put array elements in different buckets
- for (int i=0; i<n; i++)
- {
- int bi = n*arr[i]; // Index in bucket
- b[bi].push_back(arr[i]);
- }
- // 3) Sort individual buckets
- for (int i=0; i<n; i++)
- {
- sort(b[i].begin(), b[i].end());
- }
- // 4) Concatenate all buckets into arr[]
- int index = 0;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < b[i].size(); j++)
- {
- arr[index++] = b[i][j];
- }
- }
- }
- /* Driver program to test above funtion */
- int main()
- {
- vector<double> A;
- double numbers;
- while (cin>>numbers)
- {
- A.push_back(numbers);
- }
- int n = A.size();
- bucketSort(A, n);
- cout<<"Sort numbers: "<<endl;
- for (int i=0; i<n; i++)
- {
- cout<<A[i]<<" ";
- }
- }
- bucketSort_2.cpp:19:6: error: no match for 'operator=' (operand types are 'std::vector<double>' and 'double')
- b[i]=c;
- ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement