int e,culture,country,visit;//Adjacency matrix of countries and cultures
int judge(int x,int y)//Judge whether there is any conflict between the learned culture and x countries
if(culture[ country[y] ...
Added by GKWelding on Tue, 01 Mar 2022 12:31:36 +0200
4 STL function object
4.1 function object
4.1.1 function object concept
A class that overloads the function call operator. Its object is often called a function objectWhen a function object uses overloaded (), its behavior is similar to that of a function call, which is also called an imitation function
A function object ...
Added by CodeMama on Tue, 01 Mar 2022 07:30:32 +0200
Template classes vector and array are substitutes for arrays.
vector The template class vector is similar to the string class and is a dynamic array. Basically, it is an alternative to using new to create dynamic arrays. In fact, the vector class does use new and delete to manage memory, but this work is done automatically.
vector is a sequen ...
Added by brandond on Mon, 28 Feb 2022 21:52:48 +0200
Stacks and queues can be considered restricted versions of arrays and linked lists.
Problem Description: match the left and right parentheses of a string.
Problem solving idea: enter the stack when you encounter the left parenthesis. In case of right parenthesis, it will be out of the stack. If th ...
Added by Lauram340 on Mon, 28 Feb 2022 16:29:22 +0200
The three characteristics of C + + object-oriented are encapsulation, inheritance and polymorphism The meaning of encapsulation is to take the attributes and behavior as a whole, express or even the food in, and control the attributes For example, human attributes include not only inherent attributes such as age, height and weigh ...
Added by rajatr on Mon, 28 Feb 2022 14:40:53 +0200
Chapter I basic algorithm (I)
1, Content overview
Master the main ideas and have a deep understanding
Understand and memorize the code template (master the idea)
Template topic exercise
Understanding + memory
Quick rowMerge sort
2. Two points
Integer dichotomyFloating point binary
2, Quick sort
The main idea of ...
Added by orbitalnets on Mon, 28 Feb 2022 14:09:13 +0200
1.1 generic programming
First, let's add two numbers
int Add(int x, int y)
return x + y;
double Add(double x, double y)
return x + y;
char Add(char x, char y)
return x + y;
Although function overloading can be implemented, there are several disadvantages:
Overloaded functions only have different types, and ...
Added by mapleleaf on Mon, 28 Feb 2022 13:19:28 +0200
New solution of sequence query
The previous question "sequence query" said: A=[A0,A1,A2 ···, An] is a sequence composed of n+1 integers in the range of [0,N], which satisfies 0 = A0 < A1 < A2 < ·· < An < n. Based on sequence a, for any integer x within the range ...
Added by Eggzorcist on Mon, 28 Feb 2022 09:05:33 +0200
Template meta programming example - how to design a general geometry Library
Suppose you need to use a c + + program to calculate the distance between two points You might do this:
First define a struct:
double x, y;
Then define a function containing the calculation algorithm:
double distance(myp ...
Added by Skaara on Sun, 27 Feb 2022 06:25:57 +0200
2, Encapsulation (Part 2)
4.1 object arrays and object members
(1) Object array
Many times, we need not only one object, but a group of objects. For example, if there are 50 students in a class, we can use the object array. [object array code practice] Title: define a Coordinate class whose data members contain abscissa and ordinate. In ...
Added by martins on Sun, 27 Feb 2022 06:00:56 +0200