Sha256: 8bedc961992f2265a7deca88f53a04d5cc20fe14b3753797c4272b270959fd21
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
--- layout: implementation title: Bubble Sort --- {% highlight ruby %} #include <iostream> #include <vector> #include <stdlib.h> using namespace std; vector<int> bubble_sort(vector<int> numbers) { for(int i = 0; i < 9; i++) { for(int j = i; j < 9; j++) { if (numbers[i] > numbers[j]) { int temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } } } return numbers; } int main() { vector<int> numbers; int max, v; // Reading the input cin >> max; for (int i = 0; i < max; i++) { cin >> v; numbers.push_back(v); } numbers = bubble_sort(numbers); // Printing the output for (int i=0; i< 8; i++) cout << numbers[i] << " "; cout << numbers[8] << endl; return 0; } {% endhighlight %}
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jeka-0.1.1 | test/site/cpp.textile |
jeka-0.1.0 | test/site/cpp.textile |