C LanguageThere are many ways to exchange variables in:
1. Use intermediate variables for exchange
Pointer mode:
Swap (int * P1, int * P2) {int P; P = * P1; * P1 = * P2; * P2 = P ;}
Reference variable mode:
Void swap (Int & A, Int &
The so-called array reference refers to the array reference;
For example, int A [10];
INT (& B) [10] =;
If it is written as int A [10];
Int * & B =;
The following error occurs: cannot convert from 'int [10] 'to 'int *&'.
Maybe you will say that the
P41
The variable name, that is, the identifier, cannot contain two consecutive underlines, nor can it start with followed by an uppercase letter.
I have verified that the compilation can be completed in G ++. I wonder if the translation is
Compile C in LinuxProgramWhile compiling C ++ programs using gcc, G ++ is required. Compiling C ++ programs using gcc produces an error: Undefined reference to 'std: ios_base: init :: init (). Use the GCC-lstdc ++ compilation option. Or use g ++.
The earliest C compiler does not check the subscript, but the latest compiler does not check it. This task is difficult because subscript reference can be used as any pointer, not just an array name.
The effectiveness of the subscript reference
The C-identifier link has three forms: External link identifier, internal link identifier, and non-link identifier.
External link identifier: the Storage Class Identifier is decorated with extern, or does not have such modifier (the default is
# Include Using namespace STD;
// By default, the length of the dynamic array is 2.
Template Class Array{Public:Array (INT size = 2 );Array (const array & copy );Array & operator = (const array & right );~ Array ();Datatype & operator [] (INT
Template Struct Node{Datatype Info;Node * next;};
Template Class program list{Public:Vertex list ();~ Vertex list ();Consumer list (const consumer list & copy );Operator list & operator = (const operator list & right );Void insert (const
15. compilation process
File. C, file. h goes throughPre-processorProcess it as file. I, and then go throughCompiler(GCC) to compile file. s, and thenAssembler(AS) becomes file. O, and finally passesConnector(Linker) becomes an executable
11. Analysis of logical operators
& | Short Circuit Rule: | calculates from left to right. If a condition is true, the calculation is stopped. The entire expression is true. If all conditions are false, the expression is false.
& Calculate from left
29. Dynamic Memory Allocation
Why dynamic memory allocation: everything in C language is based on memory, variables and arrays are aliases of memory, and how to allocate these memories is determined by the compiler during the compilation period, if
Http://bbs.csdn.net/topics/370153775
I often see the following questions in some discussion groups: "Who knows what value the C statement assigns to n ?"M = 1; n = m ++ M ++;
Recently, an unfamiliar friend sent me an email asking why two 4
In Linux programming, batch file processing is sometimes used. For example, if you write an upload tool and enter a file name, if you are using a matched file name, the program should automatically search for a file name that meets the requirements
The static members in the class are really a fascinating feature. I decided to summarize the knowledge points of static class members so that I would not be passive in future interviews.Static class members include static data members and static
This function obtains a value a [n] (N ≥1) with 0 or 1 as the original value, and determines whether the size of each continuous sequence with 1 is an even number.
# Include Using namespace STD;Bool fun (int * a, int N){Int I = 0; int coun = 0;While
Problem
1> 0 ~ 5% 2> 5% ~ 60% 3> 60% ~ 100%
Use rand () to generate probability
C implementation
# Include # include # include // before use this srand must be invoked. // probs must be ascending order and all of them shocould not greater than 1.
// Left-aligned output and right-aligned output/*-----------------------# Include# IncludeVoidMain () {cout // Set left-aligned output with spaces behind# Include# IncludeVoidMain () {cout // Set the right-aligned output with spaces in front
# Include # Include # Include /* The rule of this game is: The computer is in the 9 numbers 1-9,Randomly select 4 numbers into a 4-digit number, and then let the players guessThis number. Each time you input a number, the computer outputs the
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