Answered You can hire a professional tutor to get the answer.

QUESTION

C++ Programming: Replace the array with an STL container that supports operator 2. Use STL algorithms replacing existing logic where possible 3.

C++ Programming:

1. Replace the array with an STL container that supports operator []

2. Use STL algorithms replacing existing logic where possible

3. Use lambda expressions or functors to support sorting

void algorithm(int* arr, int n)

{

          int count = 0;

          for (int i = 0; i < n; i++) 

                if (arr[i] == 0)

                        count++;

           for (int i = 0; i < count; i++)

                arr[i] = 0;

           for (int i = count; i < n; i++)

                arr[i] = 1;

           // provide support for using std::sort

      sort( arr[0], arr[n-1], { functor or lambda } );

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question