Learning notes of c + + Advanced Programming 2

Warning; In modern C + +, we should avoid low-level memory operations as much as possible and use modern structures, such as containers and smart pointers. Use dynamic memory Warning: As a rule of thumb, each time you declare a pointer variable, be sure to initialize it immediately with the appropriate pointer or nullptr! For example, Figu ...

Posted by scoobydoo9749 on Wed, 22 Sep 2021 18:45:01 +0200

Brush notes (C + + implementation) pta005 continue 3n+1 conjecture

catalogue Title Description and requirements: Input format: Output format: Input example: Output example:   Question making process: Source code: deficiencies: Good night, people. Title Description and requirements: 1005 continue (3n+1) conjecture (25 points) Callatz conjecture has been described in 1001. In this subject, th ...

Posted by phpQuestioner_v5.0 on Wed, 22 Sep 2021 18:35:29 +0200

C + + problems

Qs What does the Q1 namespace do? What is the difference between Q2 cout output and printf output? Respective advantages and disadvantages? When cin is entered, it ends with a space by default cout "<<"The operator is overloaded and output according to the data type to be output, printf Is to manually operate the output content format. ...

Posted by djkanebo on Wed, 22 Sep 2021 04:11:14 +0200

Memory allocator - dynamic memory

Dynamic memory management Why is there dynamic memory allocation What kind of memory development method have we mastered so far //Create a variable int val = 20; //Local variables open up 4 bytes in stack space int g_val = 10; //The global variable opens up 4 bytes in the static area //Create an array char arr[10] = {0}; //The local ...

Posted by notonurnelly on Tue, 21 Sep 2021 21:22:38 +0200

c + + knowledge points (constantly updated)

const class A { private: const int a;//Constant object members can be initialized using the initialization list or in class public: //Constructor A() :a(0) {}; A(int x) :a(x) {};//Initialization list //const can be used to distinguish overloaded functions int getValue();//Ordinary member function int getValue() const;//A constant membe ...

Posted by mpharo on Tue, 21 Sep 2021 09:44:36 +0200

Detailed explanation of c + + priority_queue

catalogue 1. Content: 2. Examples: 1) Examples of basic types: 2) For pair comparison, first compare the first element, the first is equal, and the second is equal   3) For custom types   3. Common uses:   1. Content: Since it is a queue, the header file #include < queue > must be included first. The difference betw ...

Posted by washbucket on Tue, 21 Sep 2021 08:30:37 +0200

[sword finger Offer] double pointer

Sword finger Offer 21. Adjust the array order so that odd numbers precede even numbers Enter an integer array and implement a function to adjust the order of numbers in the array so that all odd numbers are in the first half of the array and all even numbers are in the second half of the array. Example: Input: nums = [1,2,3,4] Output:[1,3,2, ...

Posted by cdennste on Tue, 21 Sep 2021 06:24:57 +0200

Explanation of application examples of breadth first search traversal (BFS) on two-dimensional arrays

Breadth first search traversal, also known as BFS, belongs to blind search method. It is one of the search algorithms of graph. The purpose is to systematically expand and check all nodes in the graph to find results. In other words, it does not consider the possible location of the result and searches the whole graph thoroughly until it finds ...

Posted by AffApprentice on Tue, 21 Sep 2021 01:26:55 +0200

Static member variables of classes in C++.

In C language, we know that there are static variables, and the life cycle and scope are different from those of ordinary variables. In C++ classes, there are also static member variables and static member functions. First, look at the syntax of static member variables and static member functions in C++: ...

Posted by mahers on Mon, 20 Sep 2021 22:26:33 +0200

A classical probability problem (probability distribution problem)

A classical probability problem   Competition home page   My submission Time limit: 1 second for C / C + + and 2 seconds for other languages Space limitation: C / C + + 26244k, other languages 524288K 64bit IO Format: %lld Title Description   Students bit noob and lit noob (hereinafter referred to as B and L) of Niuniu univ ...

Posted by clandestine555 on Mon, 20 Sep 2021 12:36:44 +0200