Cod sursa(job #797617)
Utilizator | Data | 14 octombrie 2012 15:11:06 | |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("algsort.in");
ofstream g("algsort.out");
int N,i,j,max;
long a[N];
f>>N;
for(i=1;i<=N;i++)
f>>a[i];
for(j=1;j<=N;j++)
if(a[j]>a[j+1])
{
max=a[j];
a[j]=a[j+1];
a[j+1]=max;
}
g<<a[j];
f.close();
g.close();
return 0;
}