SHARE
TWEET

bąbelkowe

a guest Jan 24th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. void sortuj(double tab[], int n)
  7. {
  8.     for (int i = 0; i < n; i++)
  9.         for (int j = 1; j < n - i; j++)
  10.             if (tab[j - 1] > tab[j])
  11.                 swap(tab[j - 1], tab[j]);
  12.             else continue;
  13. }
  14.  
  15. int main()
  16. {
  17.     double *tab;
  18.     int n;
  19.  
  20.     cout << "Wprowadz liczbe elementow: ";
  21.     cin >> n;
  22.    
  23.     tab = new double[n];
  24.  
  25.     cout << "Wprowadz liczby" << endl;
  26.     for (int i = 0; i < n; i++)
  27.     {
  28.         cin >> tab[i];
  29.     }
  30.  
  31.     sortuj(tab, n);
  32.  
  33.     for (int i = 0; i < n; i++)
  34.     {
  35.         cout << tab[i] << " " ;
  36.     }
  37.  
  38.     cout << endl;
  39.     system("pause");
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top