All pastes #761213 Raw Edit

Something

public text v1 · immutable
·published 2007-11-04 18:28 UTC
rendered paste body
#include <iostream>
#include <vector>

template< typename Container > void sort( Container & con ){
	int len = con.size();
	int n, l;
	bool c = false;
	a:
	for( int i = 0; i < len-1; i++ ){
		n = con[i];
		l = con[i+1];
		if( n > l ){
			c = true;
			con[i] = l;
			con[i+1] = n;
		}
		if( i == len -2 &&  !c )
			return;
	}
	c = false;
	goto a;
}

int main(){
	std::vector<int> vec;
	
	vec.push_back( 18 );
	vec.push_back( 8 );
	vec.push_back( 3 );
	vec.push_back( 5 );
	vec.push_back( 1 );
	
	sort< std::vector<int> >( vec );
	
	std::vector<int>::iterator iter = vec.begin();
	while( iter != vec.end() ){
		std::cout<< *iter<< std::endl;
		iter++;
	}
	return 0;
}

/*saida
./teste
1
3
5
8
18
*/