Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Header.h"
- #include <thread>
- #include <string>
- #include <windows.h>
- #define SQR(Y) (Y)*(Y)
- #define IS_DEBUG
- const int week_end = 7;
- using namespace std;
- template <class T>
- void quickSortR(T a[], long N) {
- // На входе - массив a[],
- // a[N] - его последний элемент.
- // поставить указатели на исходные места
- long i = 0, j = N;
- T temp, p;
- p = a[N / 2]; // центральный элемент
- // процедура разделения
- do {
- while (a[i] < p) i++;
- while (a[j] > p) j--;
- if (i <= j) {
- temp = a[i];
- a[i] = a[j];
- a[j] = temp;
- i++;
- j--;
- }
- } while (i <= j);
- /*
- рекурсивные вызовы, если есть,
- что сортировать
- */
- if (j > 0) quickSortR(a, j);
- if (N > i) quickSortR(a + i, N - i);
- }
- void test_sort() {
- srand(time(NULL));
- const long SIZE = 10;
- int ar[SIZE];
- // до сортировки
- for (int i = 0; i < SIZE; i++) {
- ar[i] = rand() % 100;
- cout << ar[i] << "\t";
- }
- cout << "\n\n";
- /*
- const long SIZE = 10;
- int ar[SIZE]{ 3,4,5,2,5,6,1,2,9,10 };
- */
- quickSortR(ar, SIZE - 1);
- // после сортировки
- for (int i = 0; i < SIZE; i++) {
- cout << ar[i] << "\t";
- }
- cout << "\n\n";
- }
- void test_macros() {
- #ifdef IS_DEBUG
- cout << "This is DEBUG";
- #else
- cout << "This is RELEASE";
- #endif // !IS_DEBUG == 0
- cout << SQR(2 + 3) << endl;
- }
- struct ManID {
- int age = 0;
- std::string name = "Jon Dou";
- int pasport_id[6]{7,4,7,7,5,7};
- void show() {
- cout << name << endl;
- }
- };
- void show_man(ManID &man) {
- cout << man.age << " " << man.name << endl;
- }
- void test_struct() {
- enum MODE {ON, OFF};
- MODE reg1 = MODE::ON;
- MODE reg2 = MODE::OFF;
- enum {LEFT, RIGHT, MIDLE} reg3 = LEFT;
- ManID first;
- first.age = 17;
- first.name = "Petya";
- //cout << first << endl;
- cout << first.age << " " << first.name << endl;
- ManID second{32, "Masha"};
- cout << second.age << " " << second.name << endl;
- show_man(first);
- show_man(second);
- cout << first.pasport_id[3] << endl;
- ManID mans[100];
- std::string str1 = "Hi everybody";
- cout << str1.length() << endl;
- mans[20].show();
- }
- struct Wear {
- std::string name;
- int hp;
- int armor;
- int damage;
- };
- struct Warior {
- std::string name = "Y";
- int hp = 100;
- int armor = 0;
- int damage = 0;
- Wear wear[10];
- };
- void game() {
- Warior person1, person2;
- cout << "Pl1: Enter name: ";
- getline(cin, person1.name);
- cout << "Pl2: Enter name: ";
- getline(cin, person2.name);
- person1.wear[0].name = "Sword";
- person1.wear[0].damage = 10;
- person2.wear[0].name = "Foots";
- person2.wear[0].armor = 3;
- }
- int main() {
- for (int k = 0; k < 1000; k++) {
- cout << k;
- Sleep(0.25);
- system("cls");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement