SHARE
TWEET

Untitled

a guest Oct 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. #include <unistd.h>
  4.  
  5. using namespace std;
  6. void swap_(int &a, int &b){
  7.     int c=a;
  8.     a=b;
  9.     b=c;
  10. }
  11. int main (){
  12.     int arr [10];
  13.     arr[0]=6;
  14.     arr[1]=9;
  15.     arr[2]=2;
  16.     arr[3]=4;
  17.     arr[4]=8;
  18.     arr[5]=3;
  19.     arr[6]=18;
  20.     arr[7]=7;
  21.     arr[8]=0;
  22.     arr[9]=1;
  23.  
  24.     int n = 10;
  25.     int t=arr[0];
  26.     for (int p=0; p<n-1; p++){
  27.         if (arr[p] > arr[p+1]){
  28.             //cout << arr[p] <<  endl;
  29.             swap_(arr[p], arr[p+1]);
  30.         }
  31.     }
  32.     for (int i = 0; i < n; i++) {
  33.         cout << arr[i] << " ";
  34.     }
  35.     cout << endl;
  36.  return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top