排列问题
template<class T>inline void swap( T& a, T& b )
{
T tmp = a;
a = b;
b = tmp;
}
template<class T>
void Perm( T list[], int start, int end )
{
int i;
if ( start == end )
{
for ( i = 0; i <= end; i++ )
cout << list[i];
cout << endl;
}
else
for ( i = start; i <= end; i++ )
{
swap( list[start], list[i] );
Perm( list, start+1, end );
swap( list[start], list[i] );
}
}
这个算法中既然i=start,swap(list[strat],list[i])有什么用?