Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <time.h>
- #include <iomanip>
- #include <Windows.h>
- using namespace std;
- const int N = 10000;
- int main()
- {
- int d[N],i;
- DWORD t1,t2;
- cout<<"Sortowanie bombelkowe"<<endl<<endl;
- srand((unsigned)time(NULL));
- for(i=0; i<N;i++) d[i] = rand() % 100;
- cout<<"Przed sortowaniem"<<endl;
- for(i=0; i<N;i++) cout<<setw(4)<<d[i];
- cout<<endl;
- //algorytm sortowania
- t1 = GetTickCount();
- //____________________
- for(i=0;i<N-1;i++)
- for(int j=0;j<N-1;j++)
- if(d[j]>=d[j+1]) swap(d[j],d[j+1]);
- //____________________
- t2 = GetTickCount() - t1;
- //koniec algorytmu
- cout<<"Po sortowaniu"<<endl;
- for(i=0; i<N;i++) cout<<setw(4)<<d[i];
- cout<<endl;
- cout<<"Czas wykonania "<<t2<<" milisekund"<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement