Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void bubble_sort( int a[], int n ){
- for( int i = n-2; i >= 0; i--)
- for( int j = 0; j <= i; j++)
- if( a[j] > a[j+1] ){
- int t = a[j];
- a[j] = a[j+1];
- a[j+1] = t;
- }
- }
- int main(){
- setlocale(0,"");
- int *a, n;
- cout << "бр числа ->";
- cin >> n;
- a = new int[n];
- for( int i=0; i<n; i++ ) cin >> a[i];
- bubble_sort( a, n );
- cout << "след прилагане на сортиране по метод на мехурчето:\n";
- for( int i=0; i<n; i++ ) cout << a[i] << " ";
- delete []a;
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment