Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void bubblesort(int a[]) {
- for (int i = 0; i < 10; i++)
- {
- for(int j = 0; j < (10 - i - 1); j++)
- {
- if(a[j] > a[j+1])
- {
- int b = a[j];
- a[j] = a[j+1];
- a[j+1] = b;
- }
- }
- }
- }
- int main() {
- int array[10];
- int size;
- cout << "Unesite 10 brojeva: ";
- for (int i = 0; i < 10; i++)
- {
- cin >> array[i];
- }
- cout << "Pre sortiranja " << endl;
- for (int i = 0; i < 10; i++) {
- cout << array[i] << " ";
- }
- bubblesort(array);
- cout << "Sortirano: ";
- for (int i = 0; i < 10; i++) {
- cout << array[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement