Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int findnull(int** matrix, int n, int condition) {
- for (int i = 0; i < n; i++) {
- switch (condition) {
- case 1:
- if (matrix[0][i] == 0)
- return i;
- break;
- case 2:
- if (matrix[1][i] == 0)
- return i;
- break;
- }
- }
- }
- int findmax(int a, int b) {
- if (a > b)
- return a;
- else
- return b;
- }
- int findnumberofcolumns(int** matrix, int n) {
- for (int i = 0; i < n; i++)
- if (matrix[0][i] == 0)
- return i;
- }
- void findrow(int* start, int* sort, int n, int *index, int* length) {
- int i = *index;
- int k = 0;
- int* sort = new int[n];
- do {
- sort[k] = start[i];
- i++;
- k++;
- } while (start[i] < start[i + 1]);
- *length = i - *index;
- *index += *length;
- }
- void fillsort1(int* f1, int n, int length, int index, int* sort, int** matrix) {
- for (int i = index; i < index + length; i++)
- f1[i] = sort[i - index];
- int posnum = findnull(matrix, n, 1);
- matrix[0][posnum] = length;
- }
- void fillsort2(int* f2, int n, int length, int index, int* sort, int** matrix) {
- for (int i = index; i < index + length; i++)
- f2[i] = sort[i - index];
- int posnum = findnull(matrix, n, 2);
- matrix[1][posnum] = length;
- }
- void fillingfs(int n, int* start, int* f1, int* f2, int** matrix) {
- nullmatrix(matrix, n);
- int index = 0;
- int length = 0;
- int condition = 0;
- int* sort;
- for (int i = 0; i < n; i += length) {
- findrow(start, sort, n, &index, &length);
- if (condition % 2 == 0)
- fillsort1(f1, n, length, index, sort, matrix);
- else
- fillsort2(f2, n, length, index, sort, matrix);
- }
- }
- int calculatek(int** matrix , int i, int condition) {
- int sum = 0;
- for (int counter = 0; counter < i; counter++)
- {
- switch (condition) {
- case 1:
- sum += matrix[0][counter];
- break;
- case 2:
- sum += matrix[1][counter];
- break;
- }
- }
- return sum;
- }
- int* sortedf(int* f1, int* f2, int** matrix, int n) {
- int k1 = 0;
- int k2 = 0;
- int* f = new int[n];
- int counter = findnumberofcolumns(matrix, n);
- for (int i = 0; i < counter; i++) {
- int size1 = matrix[0][i];
- int size2 = matrix[1][i];
- findmax(size1, size2);
- if (i == 0) {
- for (int j = 0; j < size1 + size2; j++) {
- }
- }
- else{
- k1 = calculatek(matrix, i, 1);
- k2 = calculatek(matrix, i, 2);
- for (int j = 0; j < size1 + size2; j++) {
- if (
- f[k1+k2]
- }
- }
- }
- }
- void nullmatrix(int** matrix, int n) {
- int counter = n / 2 + 1;
- for (int i = 0; i < counter; i++) {
- matrix[0][i] = 0;
- matrix[1][i] = 0;
- }
- }
- int main() {
- setlocale(LC_ALL, "Russian");
- int n;
- std::cin >> n;
- int* result = new int[n];
- int* start = new int[n];
- for (int i = 0; i < n; i++)
- std::cin >> start[i];
- int* f1 = new int[n];
- int* f2 = new int[n];
- int* sort = new int[n];
- int length;
- return 0;
- }
- /* int** matrix = new int* [2];
- for (int i = 0; i < 2; i++)
- matrix[i] = new int[n / 2 + 1];
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement