Donghua advanced level oj31-40

#include<stdio.h> #include<string.h> #include<algorithm> int e[110][110],culture[110][110],country[110],visit[110];//Adjacency matrix of countries and cultures int N,K,M,S,T,learn[110],ans; 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 (understand)

4 STL function object 4.1 function object 4.1.1 function object concept 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 Essence: A function object ...

Added by CodeMama on Tue, 01 Mar 2022 07:30:32 +0200

❥ about C + + template classes vector, array VS array

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

Stack and Queue

Stack Stacks and queues can be considered restricted versions of arrays and linked lists. application parenthesis matching 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

C + + learning notes - class

preface 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 1 basic algorithm ACwing

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 1. Sorting: 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

C + + template primary and STL

Template 1 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

New solution of sequence query Topic background 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

Template meta programming example - how to design a general geometry Library design principle Suppose you need to use a c + + program to calculate the distance between two points You might do this: First define a struct: struct mypoint { 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

[C + +] object oriented encapsulation

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