Introduction to algorithm 11 -- minimum spanning tree grid length problem

1, Purpose 1. Be familiar with the basic idea of algorithm design 2. Master the idea of minimum spanning tree algorithm 2, Content and design idea The State Grid Corporation of China wants to lay out an EHV transmission network across the country and connect all provincial capitals. In order to reduce costs and meet some hard requirements, the ...

Added by jeffwhite on Sat, 13 Nov 2021 01:10:23 +0200

Sequential storage structure and chain storage structure of linear table and their simple operation (mixed use of C and C + +)

Sequential storage structure and chain storage structure of linear table and their simple operation (mixed use of C and C + +)1, Preface:In the first computer experiment when learning data structure, the teacher asked us to realize the sequential storage structure and chain storage structure of linear table and their simple operation. It was pa ...

Added by Axem on Fri, 12 Nov 2021 17:25:38 +0200

798-C + + exception handling (try catch)

C + + exception handling (try catch) The program often encounters some errors, such as divisor 0, age negative, array subscript out of bounds, etc. if these errors can not be found and handled, they may lead to program crash. The C + + exception handling mechanism allows us to catch and handle these errors, and then we can let the program cont ...

Added by kulin on Fri, 12 Nov 2021 09:03:40 +0200

[AcWing algorithm basic course] Chapter1 basic algorithm

Double pointer algorithm We have already used the double pointer algorithm in quick sort and merge sort. The first type: the first pointer points to sequence 1 and the second pointer points to sequence 2 The second type: two pointers point to the same sequence for(int i=0,j=0;i<n;i++){ while(j<i && check(i,j)) j++; // ...

Added by andrewb on Thu, 11 Nov 2021 23:08:41 +0200

[C++]C++11 shared_ Summary of PTR smart pointer usage

0x00 Preface There may be grammatical errors and punctuation errors in the text, please understand; If you find code errors or other problems in the article, please let us know. Thank you! 0x01 manual memory management In actual C + + development, we may have problems such as sudden crash during program operation due to improper manual memo ...

Added by dansk on Thu, 11 Nov 2021 11:00:46 +0200

C + + Experiment 2 -- Inheritance and polymorphism

1, Inheritance access test Source code: #include <iostream> using namespace std; class A_animal{ public: void eat(){ cout << "need eat" << endl; } protected: void sleep(){ cout << "need sleep" << endl; } private: void stand(){ cout << "can stand up" << endl; } }; //Here is su ...

Added by jug on Wed, 10 Nov 2021 22:36:49 +0200

Simple implementation of fixed length memory pool

catalogue preface 1, Fixed length memory pool         1.1 concept         1.2 realization         1.2.1 introduction to member variables         1.2.2 introduction to member functions           1.2.3 details     &nbs ...

Added by ronjon on Wed, 10 Nov 2021 20:49:34 +0200

cmp function in qsort()

Basic form: int cmp(const void *a ,const void *b); Analyze this basic form: The return value of the function is int The formal parameters are two const void *, which means that the two parameters are of const void * type, that is, a pointer. Const represents that the value of the memory unit pointed to by the pointer cannot be changed. Void ...

Added by Siggles on Wed, 10 Nov 2021 11:43:45 +0200

C + + programming and object model design

C + + programming and object model design Conversion function #include <iostream> class Fraction { public: Fraction(int num, int den = 1) : m_numerator(num), m_denominator(den) {} operator double() const { return ((double)m_numerator/m_denominator); } private: int m_numerator; // molecule int m_denominator; // denominat ...

Added by whitelion on Wed, 10 Nov 2021 08:32:49 +0200

Effective C + + learning notes (Clause 21: when an object must be returned, don't try to return its reference)

Recently, I started to watch Effective C + +. In order to facilitate future review, I specially took notes. If I misunderstand the knowledge points in the book, please correct!!! In the previous article, we learned the high efficiency of reference passing, but this does not mean that value passing is useless. If you only want to use reference ...

Added by lazytiger on Tue, 09 Nov 2021 20:31:07 +0200