Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,i,j,temp;
- cout << "Insert Array size: ";
- cin >> n;
- int *arr=new int[n];
- cout << "Insert Array Elements..." <<endl;
- for(i=0; i<n; i++)
- {
- cin >> arr[i];
- }
- for(j=0; j<n-1; j++)
- {
- for(i=j+1; i<n; i++)
- {
- if(arr[j]>arr[i])
- {
- temp = arr[j];
- arr[j] = arr[i];
- arr[i] = temp;
- }
- }
- }
- cout << "Sorted Array is...."<<endl;
- for(i=0; i<n; i++)
- {
- cout << arr[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment