Category:C++

  • [C + + Primer Plus] answers to programming exercises – Chapter 8

    Time:2021-10-25

    1 void ch8_1_print(const std::string & str, int n = 0 ) { 2 using namespace std; 3 static int flag = 0; 4 ++ flag; 5 if (!n) 6 cout << str << endl; 7 else { 8 for (int i = flag; i; — i) 9 cout << str << endl; 10 } 11 […]

  • Implement a simple STL allocator

    Time:2021-10-24

    1. General This paper implements a simple allocator and briefly explains the internal implementation process of new / delete. 2. A simple STL allocator STL allocator is the space configurator in the container. STD:: allocator is the default of the standard library. Its main functions are memory allocation and release, object construction and deconstruction. It […]

  • [C + + Primer Plus] answers to programming exercises – Chapter 9

    Time:2021-10-23

    1 // chapter09_golf.h 2 3 #ifndef LEARN_CPP_CHAPTER09_GOLF_H 4 #define LEARN_CPP_CHAPTER09_GOLF_H 5 6 #include 7 #include 8 9 const int Len = 40; 10 struct golf { 11 char fullname[Len]; 12 int handicap; 13 }; 14 15 void setgolf(golf &, const char *, int); 16 int setgolf(golf &); 17 void handicap(golf &, int); 18 void showgolf(const […]

  • Dry goods: explain the CMP parameters of C + + sort function in detail!

    Time:2021-10-22

    On the first day of learning algorithms, you were learning bubble and bucket row When you haven’t figured out fast platoon and merge You have learned the final heap sorting and Hill sorting of data structures It can be said that ranking is a nightmare for many competition students So it was born void std::sort() […]

  • Compile a GCC cross compilation tool chain from scratch

    Time:2021-10-21

    In order to avoid coupling with the host compilation system, many SDKs and software that need to be associated with customers will provide their own tool chain or require the customer’s system to meet some tool chain requirements. The advantages of an independent toolchain are as follows: one   Don’t worry about the host operating […]

  • Starting with a glibc bug spanning 20 years

    Time:2021-10-20

    one   origin These days, I adjusted the cross compilation tool chain of GCC 7.5.0 + glibc 2.23. Because werr is opened by default in GCC 7.5.0, I accidentally found a century bug in glibc that has been hidden for 20 years. This bug was introduced at the beginning of glibc version 2.0, but it […]

  • [C + + Primer Plus] answers to programming exercises – Chapter 10

    Time:2021-10-19

    1 // chapter10_1_account.h 2 3 #ifndef LEARN_CPP_CHAPTER10_1_ACCOUNT_H 4 #define LEARN_CPP_CHAPTER10_1_ACCOUNT_H 5 6 #include 7 #include 8 9 10 class Account { 11 private: 12 std::string name_; 13 std::string id_; 14 double deposit_; 15 public: 16 Account(); 17 Account(std::string,std::string,double); 18 void show() const; 19 bool in(double); 20 bool out(double); 21 }; 22 23 24 #endif //LEARN_CPP_CHAPTER10_1_ACCOUNT_H […]

  • Codeforces 1365D Solve The Maze

    Time:2021-10-18

    Main idea of the title: In a\(n * m\)In the matrix, there are open spaces, bad people, good people and walls. You can turn the open space into a wall to block the bad guys.\((n, m)\)For export, is there a scheme that enables all good people in the matrix to go to the export, while […]

  • Large and small end storage

    Time:2021-10-17

    0. Problem introduction   If definition: int a   = 1;   We know that when a is stored in memory, it should be 0x 01 00 00 01, but we see that what is stored in memory is 0x 01 00 00 00 00, which is the problem of large and small end storage.   […]

  • 2021.9.20 simulation game summary + problem solution

    Time:2021-10-16

    catalogue summary Make up 2526 Meaning: deduction: code: Minimum product Meaning: deduction: code: rain Meaning: deduction: code: First find F1 Find FN, go backwards Complete code Dyeing: Meaning: deduction: code: summary This test is a thinking question. I only made the rain. My thinking is not agile enough. I have to practice Question 1: 0 […]

  • C + + string encoding conversion

    Time:2021-10-15

    There are many kinds of strings in C + +. For details, refer toString types in C + +。 This article mainly takes string type as an example to talk about string encoding. String is selected mainly because: Byte is the minimum structure of binary encoding of string. String is essentially an array of bytes […]

  • Counting

    Time:2021-10-14

    preface During the summer vacation, I saw an interview question from Tencent while watching C + + face to face. The main idea of the problem is to find the value of (2 ^ 1e10)% 10000, which limits the time complexity. There are no large numbers in Java and python in C + +. I […]