Facebook
From Chunky Zebra, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 1025
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "math.h"
  4. #include "cstdlib"
  5. #include "string"
  6. #include "iomanip"
  7. #include "ctime"
  8. #include "windows.h"
  9. #include "conio.h"
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14.  
  15. {
  16.         int n = 10;
  17.         int losuj[11];
  18.         int tab1;
  19.         int pom;
  20.  
  21.         for (int i = 0; i < n; i++)
  22.         {
  23.                 cout << "Podaj " << i + 1 << " liczbe: ";
  24.                 cin >> losuj[i];
  25.         }
  26.        
  27.         cout << "Sortowanie wykonano metoda babelkowa:" << endl;
  28.  
  29.         for (int i = 0; i < n; i++)
  30.                 for (int j = 0; j<n - i - 1; j++)
  31.                         if (losuj[j]>losuj[j + 1])
  32.                         {
  33.                                 pom = losuj[j];
  34.                                 losuj[j] = losuj[j + 1];
  35.                                 losuj[j + 1] = pom;
  36.                         }
  37.         for (int j = 0; j < n; j++)
  38.                 cout << losuj[j] << " ";
  39.         cout << "\n";
  40.  
  41.         system("pause");
  42.         return 0;
  43. }
  44.