Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
1.1 kB
3
Indexable
Never
#include <iostream>
#include <vector>

using namespace std;

std::vector<int> Merge(const std::vector<int>& v1, const std::vector<int>& v2) {
    //...
}

std::vector<int> MergeSort(const std::vector<int>& v) {
    std::vector<int> v1(v.begin(), v.begin() + v.size() / 2);
    std::vector<int> v2(v.begin() + v.size() / 2, v.end());
    return Merge(MergeSort(v1), MergeSort(v2));
}

void MergeSort(std::vector<int>& v) {
  int l1 = sizeof(v) % 2;
  int l2 = sizeof(v) - l1;

  vector<int> v1(l1);
  vector<int> v2(l2);
  for (int i = 0; i < sizeof(v); i++) {
    if (i < l1)
      v1[i] = v[i];
    else
      v2[i - l1] = v[i];
  }
  if (l1 > 1) MergeSort(v1);
  if (l2 > 1) MergeSort(v2);
  for (int i = 0; i < sizeof(v); i++) {
      int j = 0;
      int k = 0;
      while (v2[j] < v1[i]){
          v[i] = 
      }
  }
}

int main() {
  std::vector<int> v(10);
  v[0] = 4;
  v[1] = 9;
  v[2] = 3;
  v[3] = 2;
  v[4] = 4;
  v[5] = 3;
  v[6] = 7;
  v[7] = 12;
  v[8] = 8;
  v[9] = 0;
  MergeSort(v);
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << endl;
  }
}