hi, i created a program to use bubblesort to sort numbers in an array, but when i try to display the new array, nothing appears on the command prompt. after some exploring, i figured out that it gets stuck in one of the loops in the sorting function. here is the code:
#include <iostream>
using namespace std;
void swap ( int &a, int &b )
{
a = a ^ b;
b = a ^ b;
a = a ^ b;
}
void PrintArray ( int *in, int l )
{
for ( int i = 0; i < l; i++ )
{
cout << in[i];
}
}
void BubbleSort ( int *in, int l )
{
int n = l - 1;
int t = 1;
int i;
while ( t = 1 )
{
t = 0;
for ( i = 0; i < n; i++ )
{
if ( in[i] > in[i+1] )
{
t = 1;
swap (in[i],in[i+1]);
}
}
}
}
int main()
{
int array[5] = {23,11,65,34,1};
BubbleSort (array,5);
PrintArray (array,5);
cin.get();
}
can someone please tell me what i did wrong?