Advertisement
mostlabs

6/2

Dec 11th, 2019
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.    
  9.    
  10.     unsigned short n;
  11.  
  12.        cout << "n = ";
  13.        cin >> n;
  14.        float* mas = new float[n];
  15.        
  16.  
  17.      for (int i = 0; i < n; i++)
  18.          cin >> mas[i];
  19.          
  20.          
  21.     for(int i=0 ; i < n ; i++)
  22.         cout << mas[i] << " " ;
  23.    
  24.    cout << endl;
  25.    
  26.    
  27.     for(int i=0; i < n; i ++){
  28.     for(int j=0 ; j < n-1 ; j++){
  29.     if(mas[j] > mas[j+1]){
  30.         int t=mas[j];
  31.         mas[j]=mas[j+1];
  32.         mas[j+1]=t;
  33.     }
  34.     }
  35.    
  36.    
  37.     }
  38.    
  39.     for(int i=0; i < n ; i++)
  40.     cout << mas[i] << " ";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement