Advertisement
diofa

CPP sorted number

Oct 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. /*
  2. *Source code by diofaprogsoft
  3. */
  4. #include <stdio.h>
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main(){
  9.     int A[10],tmp; int n,i,j;
  10.    
  11.     cout<<"Enter the number of times input value : ";
  12.     cin>>n;
  13.     cout<<"\n";
  14.    
  15.     for(i=1;i<=n;i++){
  16.         cout << "Value - "<<i<<" : ";
  17.         cin>>A[i];
  18.     }  
  19.     cout<<"\nSorted : ";
  20.     for(j=1;j<=n;j++){
  21.         for(int k=j+1;k<=n;k++){
  22.             if(A[j]>A[k]){
  23.                 tmp=A[k];
  24.                 A[k]=A[j];
  25.                 A[j]=tmp;
  26.             }
  27.         }
  28.         cout<<A[j]<<" ";
  29.     }  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement