Pagini recente » Cod sursa (job #3279722) | Info Oltenia 2019 | Cod sursa (job #588191) | Cod sursa (job #719120) | Cod sursa (job #612457)
Cod sursa(job #612457)
#include<iostream>
#include<fstream>
using namespace std;
void sort(double& a, double& b)
{double aux; aux=a;a=b; b=aux;}
int main()
{int gasit,i,n;
double v[500000];
ifstream f("algsort.in");
ofstream t("algsort.out");
f>>n;
for(i=0;i<n;i++){f>>v[i]; cout<<v[i]<<" ";} cout<<"\n";
do{ gasit=0;
for(i=0;i<n-1;i++)
if(v[i]>v[i+1]){sort(v[i],v[i+1]); gasit=1;}
}while(gasit==1);
for(i=0;i<n;i++)t<<v[i]<<" ";
return 0;
}