Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <unistd.h>
- using namespace std;
- void swap_(int &a, int &b){
- int c=a;
- a=b;
- b=c;
- }
- int main (){
- int arr [10];
- arr[0]=6;
- arr[1]=9;
- arr[2]=2;
- arr[3]=4;
- arr[4]=8;
- arr[5]=3;
- arr[6]=18;
- arr[7]=7;
- arr[8]=0;
- arr[9]=1;
- int n = 10;
- int t=arr[0];
- for (int p=0; p<n-1; p++){
- if (arr[p] > arr[p+1]){
- //cout << arr[p] << endl;
- swap_(arr[p], arr[p+1]);
- }
- }
- for (int i = 0; i < n; i++) {
- cout << arr[i] << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement