Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- void swap(int &a,int &b)
- {
- int temp;
- temp = b;
- b = a;
- a = temp;
- }
- int main()
- {
- int array[]={7,1,5,9,2};
- for (int i=0;i<5;i++){
- for (int j=i+1;j<5;j++){
- if (array[i] > array[j]){
- swap(array[i],array[j]);
- }
- }
- cout<<array[i]<<" ";
- }
- cout<<endl;
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement