Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- using namespace std;
- long a[51];
- int n,m,k=1;
- void citire()
- {
- ifstream fin("sort.in");
- fin>>n;
- for (int i=1; i<=n; i++)
- fin>>a[i];
- }
- void prelucrare()
- {
- ofstream fout("sort.out");
- int i,j;
- long aux,min;
- for(i=1;i<=n-1;i++)
- {
- min=a[i];
- k=i;
- for(j=i+1;j<=n;j++)
- if(a[j]<min)
- {
- min=a[j];
- k=j;
- }
- aux=a[i];
- a[i]=a[k];
- a[k]=aux;
- }
- for(i=1;i<=n;i++)
- fout<<a[i]<<" ";
- }
- int main()
- {
- citire();
- prelucrare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement