こんばんは、よろしくお願いします。

>>132 の 5) バブルソート。
色気を出して関数にしてみました。

#include <iostream>
#include <time.h>
#define QTY 100

using namespace std;

void output( int array[], int qty, char mess[] )
{
 cout << mess << endl;
 for ( int i = 0; i < qty; ++i ) {
   cout << array[ i ] << endl;
 }
}

void bsort( int array[], int qty )
{
 int temp, i, n;
 for ( i = qty -1; i > 0; --i ) {
   for ( n = qty - 1; n > 0; --n ) {
     if ( array[ n ] < array[ n - 1 ] ) {
       swap( array[ n - 1 ], array[ n ] );
     }
   }
 }
}

int main( void )
{
 int list[ QTY ];
 srand( (unsigned)time( NULL ) );
 for ( int i = 0; i < QTY; ++i ) {
   list[ i ] = rand();
 }
 output( list, QTY, "ソート前" );
 bsort( list, QTY );
 output( list, QTY, "ソート後" );
 return( 0 );
}