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 flag=0;
- int array[]={7,1,5,9,2};
- for (int i=0;i<5;i++){
- flag = i;
- for (int j=i+1;j<5;j++){
- if (array[flag] > array[j]){
- flag = j;
- }
- }
- swap(array[flag],array[i]);
- cout<<array[i]<<" ";
- }
- cout<<endl;
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement