Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n=10;
- int a[10] = {5,3,8,1,2,9,6,4,0,7};
- // cu selection sort:
- for(int i=0; i<n-1; i++)
- for(int j=i+1; j<n; j++)
- if (a[i]>a[j])
- {
- int aux = a[i];
- a[i]=a[j];
- a[j]=aux;
- }
- // cu bubble sort;
- int schimbare=1;
- while(schimbare==1)
- {
- schimbare = 0;
- for(int i=0; i<n-1; i++)
- if (a[i]>a[i+1])
- {
- int aux = a[i];
- a[i]=a[i+1];
- a[i+1]=aux;
- schimbare=1;
- }
- }
- for(int i=0; i<n; i++)
- cout << a[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement