SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 81 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. using namespace std;
  5.  
  6. void swap_(float & a,float & b){
  7.     float c = a;
  8.     a = b;
  9.     b = c;
  10. }
  11. int ps (float arr[], int n){
  12.  
  13.  
  14.  
  15. for(int j=4;j>0;j--){
  16. for (int t=0;t<n-1;t++){
  17.     if (arr[t] > arr[t+1]){
  18.         swap_(arr[t],arr[t+1]);
  19.     }
  20.  }
  21. }
  22.  
  23. }
  24.  
  25.  
  26. int main(){
  27.     float arr[5];
  28.     int n = 5;
  29.     arr[0]=21.5; arr[1]=7.7; arr[2]=9.2;arr[3]=8.6; arr[4]=1.9;
  30.    ps(arr , n);
  31.    for (int t=0;t<5;t++){
  32.        cout<< arr[t] <<endl;
  33.    }
  34.  
  35.     return 0;
  36. }
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