Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i , j ;
- int size , temp ;
- cout << "Enter the size of the array : " ;
- cin >> size ;
- int array[size];
- for (i = 0 ; i < size ; i++)
- {
- cout << "Enter a number : ";
- cin >> array[i];
- }
- for (i = 0 ; i < size ; i++)
- {
- for (j = 0 ; j < size-i-1 ; j++)
- {
- if (array[j] > array[j+1])
- {
- temp = array[j];
- array[j] = array[j+1];
- array[j+1] = temp;
- }
- }
- }
- for (i = 0 ; i < size ; i++)
- {
- cout << array[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement