Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include <fstream>
- #include<string>
- #include<sstream>
- using namespace std;
- ofstream out("C:\\Users\\Darkman\\Downloads\\output.txt");
- selectionsort(int a[],int n)
- {
- int k=0;
- int t;
- for(int i=0; i<n-1; i++)
- {
- t=i;
- for(int j=i+1; j<n; j++)
- {
- if(a[t]>a[j])
- {
- k=k+(j-t);
- t=j;
- }
- }
- int temp=a[i];
- a[i]=a[t];
- a[t]=temp;
- }
- cout<<k<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement