answersLogoWhite

0

template<class T>

void exch( T& x, T& y )

{

T tmp=x;

x=y;

y=tmp;

}

template<class T>

void bubble_sort( T A[], size_t size )

{

size_t last_exch, left, right;

while( size )

{

for( left=0, right=1, last_exch=left; right<size; ++left, ++right)

if( A[right]<A[left] )

exch( A[left], A[last_exch=right] );

size = last_exch;

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you write a c plus plus program to sort a vector of strings using MSD radix sort?

The standard library sort algorithm automatically uses MSD radix to sort strings: std::vector&lt;std::string&gt; vs = {"a", "b", "c" "d", "ab"}; std::sort(vs.begin(), vs.end()); After sorting, the order will be: {"a", "ab", "b", "c", "d"}


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


Types of sort in c plus plus?

There's only one type of sort in C++; std::sort. If you want other types you'll need to write your own.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


How do you write program to convert meter to kilometer in c plus plus?

Divide it by 1000.


Do I need to write a program to find a substring in a given string in c plus plus?

No.


What are the home application of c plus plus programming language?

C++ is useful when you want to write a program which you can use for your home use. For instance, you have a lot of different files. You can use C++ to sort them out using file extensions. Or you can write a program which will keep track of programs and music you download and so on.


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


Write a program in c plus plus to compute first of non-terminal?

there is no solution of this problem...........that's it..........


How many classes can we write in a single c plus plus program?

Its limited only by available memory.


What is the sort cut for running c plus plus program?

It depends on the particular IDE. Visual Studio uses &lt;Ctrl&gt;F5 to start a program in non-debug mode, and F5 to start a program in debug mode.