answersLogoWhite

0

#include<iostream>

#include<array>

#include<cassert>

void sort (int* arr, const size_t size)

{

for (size_t pos=1; pos<size; ++pos)

{

int stored = arr[pos];

int gap = pos;

int previous = gap-1;

while (gap && stored<arr[previous])

{

arr[gap] = arr[previous];

gap = previous--;

}

arr[gap] = stored;

}

}

int main()

{

std::array<int, 10> a = {5, 3, 8, 1, 9, 6, 2, 0, 4, 7};

sort (a.data(), a.size());

for (size_t x=1; x<a.size(); ++x)

assert (a[x-1]<a[x]);

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

How do you implement insertion into AVL tree in C plus plus?

See related links for an example.


Sample programs in c plus plus language using pointers?

#include int main (int argc, char **argv){int i;for (i=0; i


How many codes are in Hammurabi's code?

282 rules, plus an epilogue and a prologue.


Sample questions for plus one commerce exam?

notice


Programming codes under classes in c plus plus?

Are called methods.


Can a call from denmark have the codes plus 28 or plus 455 or plus 950?

The country code for Denmark is +45, so the second one is possible. Country codes +28 and +950 are invalid.


Write in c-in and c-out in c plus plus and C programming?

In c++, to manipulate output & input you must use cin and cout. I will write a sample program to show you:#include //possibly iostream.husing namespace std; //This is what lets you use cin & coutint main(){cout


Petz dogz pack codes?

havfunspeedyshrillthrillvetpetwetpetaptcayfunpaldgzpakoceanwshizzlstinkophycicpswornsasooncheextlardsidumbelpetpetthirstedrcfvsparkystardmrejectbatmandgzrckhawaiichristilovevand i believe that is it... but you can always check (just to make sure) by going to other websites and using the codes i gave you(plus the other ones)btw if you have a moshi monsters add me i am superbluhoo2 (i no that has nothing to do with this but just do it)


Which stream functions in c plus plus control the formatting of input and output values of a class?

None of them. To control the formatting of your classes, you must overload the stream insertion and extraction operators.


What are the emergency codes for passtime plus?

999 999


Do Nike football plus codes work?

yes


What are the codes for jacaranda plus?

look in your test book