#include
#include
#include
using namespace std;
void bubbleSort(int a[], int l, int r);
void exchange(int &x, int &y);
void write(int a[], int r);
int main()
{ srand (static_cast
int n, a[100], t;
do
{cout << "Unesi broj elemenata polja: ";
cin >> n;
} while (n>100);
for (int i=0;i
t=rand()%100+1;
a[i]=t;
}
write(a,n);
bubbleSort(a,0,n-1);
write(a,n);
cin.sync();
cin.get();
return 0;
}
void bubbleSort(int a[], int l, int r)
{for (int i=l;i
{
if (a[j]
{
exchange(a[j], a[j-1]);
}
}
}
}
void exchange(int &x, int &y)
{
int t=x;
x=y;
y=t; }
void write(int a[], int r)
{ for (int i=0;i
cout << a[i] << " ";
}
cout <
Post je objavljen 03.04.2013. u 00:28 sati.