Cod sursa(job #355975)
Utilizator | Simon Horatiu Hori93 | Data | 12 octombrie 2009 21:32:05 |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
using namespace std;
int main()
{
int a[100];
int n;
fin >> n;
int i, j, aux;
for ( i = 0; i < n; i++ )
fin >> a[i];
for ( i = 0; i < n; i++ )
fout << a[i] << ' ';
fout << '\n';
// Sortare
for ( i = 0; i < n - 1; i ++ )
for ( j = i + 1; j < n; j++ )
if ( a[i] > a[j] )
{
aux = a[i];
a[i] = a[j];
a[j] = aux;
}
for ( i = 0; i < n; i++ )
fout << a[i] << ' ';
fout << '\n';
return 0;
}