Skip to content

Instantly share code, notes, and snippets.

@oskimura
Created July 21, 2016 10:36
Show Gist options
  • Save oskimura/5546e716f56488f7d36bcee45bcce98d to your computer and use it in GitHub Desktop.
Save oskimura/5546e716f56488f7d36bcee45bcce98d to your computer and use it in GitHub Desktop.
#include <vector>
#include <iostream>
using namespace std;
void sort(vector<int>& array) {
int count=0;
bool flag = true;
while(1) {
flag = false;
for (int i=array.size()-2;i>=0;i--) {
if (array[i]<array[i-1]) {
count++;
int tmp = array[i];
array[i] = array[i-1];
array[i-1]=tmp;
}
}
}
}
int main() {
vector<int> array;
int n;
cin>>n;
int num;
while(cin>>num) {
array.push_back(num);
}
sort(array);
for (int i=0;i<array.size();i++) {
cout << array[i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment