ANSI C describes three functions for dynamic allocation of storage space(1) malloc the storage that allocates the specified number of bytes. The initial value in this store is not determined(2) Calloc is an object of a specified length, allocating
overload (Overload): in a C + + program, you can represent several functions that are semantically and functionally similar to the same name, but the parameters or return values are different, including type, order, or function overload.(1) The same
Single principle: The function module is independent in the program design, the function is single more to be helpful for maintenance and reuse.
For example: A lot of personal computer functions, if you want to come up with only one function to
The pointer stores the address of the memory, while the pointer is of type, such as int*,float*, a natural conjecture is that the pointer variable should store both information: address and pointer type, for example, like the following structure:
Learning C + + beginners will usually use the pointer more headaches, in fact, the concept of pointers is very simple, as long as the realization of such a simple truth can be a certain understanding of the pointer: for example, int *a = new INT[10];
Hashtable is a very important structure in practical applications, the following discussion of a simple implementation, although simple, but the part is still there.
One, Access interfaceCreate a Hashtable.Hashtable hashtable_new (int size)/size
1. What is a copy constructor:Copy constructors, of course, are copies and constructs. (In fact, a lot of names, as long as the quiet mind to think, it really is the name of it) copy is also called copy, so the copy constructor is also called the
C language DUP () function: Copying a file descriptorheader file:
#include
To define a function:
int dup (int oldfd);
Function Description: DUP () is used to copy the file descriptor that the parameter OLDFD refers to
C language Getgrgid () function: Gets the data from the group file for the specified GID
Header file:
#include #include
To define a function:
Strcut Group * Getgrgid (gid_t gid);
Function Description: Getgrgid () is
Header file:
#include
The memset () function is used to set the first n bytes of the specified memory to a specific value, which is a prototype:
void * memset (void * ptr, int value, size_t num);
Parameter description:A
Header file:
#include
The STRPBRK () function retrieves the position of the first identical character in a two string, and its prototype is:
Char *strpbrk (char *s1, char *s2);
"Parameter description" S1, s2 two
C Language Index () function: Find the string and return to the first occurrence of the positionrelated functions: Rindex, SRECHR, STRRCHR
Header files: #include
To define a function:
char * INDEX (const char *s, int c);
Function
Minimum spanning Tree prim algorithm plain versionThere are a few points to explain.
1, 2 for loops start with 2, because we usually start by default to add the first node to the build tree, so we don't need to look for it again.
2, Lowcost[i]
Some of the initialization code that is commonly used in the two-fork tree structure
#include #include typedef struct node{int data;
Node *leftchild;
Node *rightchild;
}node;
/* Initializes a binary tree sort tree.
*/void Initbinarytree (
Greedy algorithm
The so-called greedy algorithm means that when solving a problem, always make the best choice in the present. In other words, not from the overall optimal consideration, what he made is only in a sense of the local optimal solution.
The most common approach is to use the KMP string matching algorithm:
#include #include #include int get_nextval (char *pattern, int next[])
{//get the next value of the pattern int i = 0, j =-1;
Next[0] =-1;
int Patlen = strlen
The question of the eight Queens is the placing of 8 queens on a 8*8 board, which does not allow any two queens to be on the same line, the same column, and the same diagonal on the chessboard. Keywords: recursive, tracing. Common skills:It was
1, the problem description:
How do you tell if a binary tree is a substructure of another?Like what:
2/ \9 8/ \ /2 3 5/6
Having a substructure is9/ \2 3
2, analysis of the problem:the problem of binary tree algorithm can be solved by
title : Give a floating-point number sequence, take the maximum product continuous substring value, such as -2.5,4,0,3,0.5,8,-1, then remove the maximum product continuous substring is 3,0.5,8. That is, the product 3*0.5*8=12 of the 3 numbers in the
C language, the pointer is a complex but flexible knowledge point, we know that in a one-dimensional array, for an array a[],*a,a,&a, all represent A's first address, but if mixed with two-dimensional arrays, it is more complicated. For example, for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service