Cod sursa(job #2979659)
| Utilizator | Data | 15 februarie 2023 18:14:00 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");
int v[500001];
int main()
{
int n;
fin >> n;
for(int i = 1; i <= n; i++)
fin >> v[i];
for(int i = 1; i < n; i++)
{
for(int j = 1; j <= n - i; j++)
if(v[j] > v[j+1])
{
swap(v[j], v[j+1]);
}
}
for(int i = 1; i <= n; i++)
fout << v[i] <<" ";
}
