Facebook
From Coral Water Vole, 7 Years ago, written in C++.
This paste is a reply to Re: Re: Re: Untitled from Colossal Baboon - view diff
Embed
Download Paste or View Raw
Hits: 372
  1. Zad.3 laborki 10(nie wpisuje do pliku, lenistwo)
  2.  
  3. #include<stdlib.h>
  4. #include<ctime>
  5. #include<iostream>
  6. using namespace std;
  7.  
  8. void sortowanie_babelkowe(int t,int n)
  9. {
  10.         for(int i=0;i<n;i++)
  11.  {
  12.         for(int j=1;j<n-i;j++)
  13.     {
  14.        
  15.         if(t[j-1]>t[j])
  16.         {
  17.               swap(t[j-1], t[j]);
  18.    
  19.                 }
  20.         }
  21.  }
  22. }
  23.  
  24. int main()
  25. {
  26.         int n=10;
  27.         int t[n];
  28.         for(int i=0;i<10;i++)
  29.         {
  30.                 t[i]=rand() % 1001; //losowanie od 0 do 1000 + wyƛwietlenie
  31.                 cout<<t[i]<<"  ";
  32.         }
  33. cout<<endl;
  34.         sortowanie_babelkowe(t,n);
  35.         for(int i=0;i<n;i++)
  36.         {
  37.           cout<<t[i]<<" ";
  38.         }
  39.  
  40.   cout<<endl;
  41.        
  42.  
  43. return 0;
  44. }