Advertisement
rahat62

Sorting Array in c++

Feb 28th, 2024
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.     int n;
  7.     cout<<"Please Input Size of array"<<endl;
  8.     cin>>n;
  9.     cout<<"Please Input "<<n<< " Numbers"<<endl;
  10.     int arr[n];
  11.     for(int i=0;i<n;i++){
  12.         cin>>arr[i];
  13.     }
  14.     sort(arr,arr+n);
  15.     cout<<"After Sorting Array"<<endl;
  16.     for(int i=0;i<n;i++){
  17.         cout<<arr[i]<<endl;
  18.     }
  19.     return 0;
  20. }
  21.  
Tags: sorting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement