kilolilo

Untitled

Oct 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.  int n,ch,s;
  6.      cout<<"N = ";
  7.      cin>>n;
  8.      int a[n];
  9.      for (s=0;s<n;s++){
  10.          cout<<"a["<<s<<"]= ";
  11.          cin>>ch;
  12.          a[s]=ch;}
  13.  for (int i=0;i<n;i++){
  14.      for (int j=0;j<n-i-1;j++){
  15.          if (a[j]>a[j+1]){
  16.              int h=a[j];
  17.              a[j]=a[j+1];
  18.              a[j+1]=h;
  19.          }
  20.      }
  21.  }
  22.  for (int i=0;i<n;i++){
  23.      cout<<a[i]<<" > ";
  24.  }
  25. }
Add Comment
Please, Sign In to add comment