Gistrec

custom qSort

Dec 14th, 2017
426
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.63 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3.  
  4. int lines;  // Кол-во линий
  5. int lenght; // Максимальная длина строки
  6.  
  7. int** matrix; // Собственно двухмерный массив из символов
  8.  
  9.  
  10. // Фигния для сейва матрицы
  11. void saveMatrix() {
  12.     FILE *output;
  13.     fopen_s(&output, "Output.txt", "w"); // появится в папке с .exe файлом
  14.     fprintf_s(output, "%d %d\n", lines, lenght);
  15.     for (int line = 0; line < lines; line++) {
  16.         for (int symbol = 0; symbol < lenght; symbol++) {
  17.             fprintf_s(output, "%d ", matrix[line][symbol]);
  18.         }
  19.         fprintf_s(output, "\n");
  20.     }
  21. }
  22.  
  23. // Загружаем мастрицу
  24. bool loadMatrix() {
  25.     FILE *input;
  26.     fopen_s(&input, "Input.txt", "r"); // появится в папке с .exe файлом
  27.     if (input == NULL) return 0;
  28.     fscanf_s(input, "%d %d\n", &lines, &lenght);
  29.     matrix = new int*[lines];
  30.     for (int line = 0; line < lines; line++) {
  31.         matrix[line] = new int[lenght];
  32.         for (int symbol = 0; symbol < lenght; symbol++) {
  33.             fscanf_s(input, "%d", &matrix[line][symbol]);
  34.         }
  35.     }
  36. }
  37.  
  38. // Получание суммы всех четных элементов в строке
  39. int getSum(int line) {
  40.     int sum = 0;
  41.     for (int symbol = 0; symbol < lenght; symbol++) {
  42.         if (symbol % 2) sum += (int)matrix[line][symbol];
  43.     }
  44.     return sum;
  45. }
  46.  
  47. void qsort(int left, int right) {
  48.     int main = right; // Порядок опорного элемента в векторе
  49.  
  50.     int local_left = left;
  51.     int local_right = right;
  52.  
  53.     while (local_left < local_right) {
  54.         // сдвигаем левую границу пока элемент [local_right] больше [опорного элемента]
  55.         while ((getSum(local_left) >= getSum(main)) && (local_left < local_right))
  56.             local_left++;
  57.  
  58.         if (local_right != local_left) {// если границы не сомкнулись
  59.                                         // Если элемент [left] соседний с [main]
  60.                                         // Свопаем их
  61.             if (local_left + 1 == main) {
  62.                 std::swap(matrix[local_left], matrix[main]);
  63.                 // Иначе перемещаем элемент [right] на место разрешающего
  64.             } else {
  65.                 std::swap(matrix[local_left], matrix[main - 1]);
  66.                 std::swap(matrix[main - 1], matrix[main]);
  67.                 main--;
  68.             }
  69.             // сдвигаем левую границу вправо
  70.             local_right--;
  71.         }
  72.  
  73.     }
  74.     if (local_left != left) qsort(left, main - 1); // Левая часть
  75.     if (local_right != right) qsort(main, right); // Правая часть
  76. }
  77.  
  78. int main() {
  79.     loadMatrix();
  80.     qsort(0, lines - 1);
  81.     saveMatrix();
  82.     system("pause");
  83. }
Advertisement
Comments
  • Izleo
    97 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 38% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without any verification from Swapzone — instant swap).
Add Comment
Please, Sign In to add comment