Cod sursa(job #2987469)
Utilizator | Data | 2 martie 2023 13:06:16 | |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include<iostream>
#include<vector>
int main(){
int total,aux;
int n;
bool sorted=false;
std::vector<int> v;
std::cin>>total;
while(std::cin>>n){
v.push_back(n);
}
for (int i=0;i<total;i++){
sorted=true;
for (int j=1;j<total;j++){
if (v[j-1]>v[j]){
sorted=false;
aux=v[j-1];
v[j-1]=v[j];
v[j]=aux;
}
}
}
// for (int i:v){
// std::cout<<i;
}