This is a creation in Article, where the information may have evolved or changed.
1 variables
1.1 Definitions
C++
1) data type variable name ;//single variable definition
2) data type variable name = initial value;//A single variable is defined and initialized
3) data type variable name 1, variable name 2;//Use comma to define multiple same type variables at once
4) auto variable name = initial value;//automatic derivation of variables using auto keyword (c++11)
5) static data type variable name = initial value;//local static variable
6) extern data type variable name ;//declare variable (defined in other location)
C#
1) data type variable name ;//single variable definition
2) data type variable name = initial value;//A single variable is defined and initialized
3) data type variable name 1, variable name 2;//Use comma to define multiple same type variables at once
4) var variable Name = variable initial value;//c#3.0 Introduction
Python
1) variable name = variable initial value;
GO
1) var variable name data type ;//single variable declaration
2) var variable name 1, variable name 2 data type ;//multiple variable declaration
3) variable name = variable initial value ;//Direct Assignment Mode declaration
1.2 Constants
C++
Const Data Type variable Name = variable value;
#define Variable Name variable value
C#
Const Data Type variable Name = variable value;
Python
Definition of uncertainty quantity
GO
Const variable name Data type = variable value;
Const variable NAME = variable value;
2 Basic statements
2.1 SELECT statement
C++
//if StatementsifConditions//must have parentheses{//The code snippet executes when the condition is true}//if Else StatementifConditions {//The code snippet executes when the condition is true}Else{//The statement segment is executed when the condition is false}//switch StatementsSwitch(expression) { CaseConstant value1://Only integer constants are supported{//condition is constant value 1 o'clock execute code snippet} Break;//Omit break when a constant value of 2 code snippet is also executed when the condition is a constant value of 1 CaseConstant value2: {//condition is constant value 1 o'clock execute code snippet} Break;default: {Execute code snippet when//condition is other value} Break;}
C#
//if StatementsifConditions//must have parentheses{//The code snippet executes when the condition is true}//if Else StatementifConditions {//The code snippet executes when the condition is true}Else{//The statement segment is executed when the condition is false}//switch StatementsSwitch(expression) { CaseConstant value1://Support integer constants and string constants{//condition is constant value 1 o'clock execute code snippet} Break;//Omit break when a constant value of 2 code snippet is also executed when the condition is a constant value of 1 CaseConstant value2: {//condition is constant value 1 o'clock execute code snippet} Break;default: {Execute code snippet when//condition is other value} Break;}
Python
if 语句 if 条件: 语句块 ifelse语句 if 条件1: 条件1语句块 else: 语句块 ifelif语句 if 条件1: 条件1语句块 elif 条件2: 条件2语句块 else: 语句块
GO
//if 语句 if'{'必须与if同行且不可省略 } //ifelse语句 if 条件 {//'{'必须与if同行且不可省略 else {//'{'必须与else同行且不可省略 }
2.2 Cycles
C++
//for循环 for (初始化; 条件; 增量)//初始化、条件与增量均可省略 { } //while循环 while (条件) { } //dowhile循环 do { while(条件); //注意必须有';'
C#
//for循环 for (初始化; 条件; 增量)//初始化、条件与增量均可省略 { } //foreach循环 foreachin 集合或者数组) { } //while循环 while (条件) { } //do while循环 do { while//注意必须有';'
Python
//for语句 forin 序列: 代码段 else: 代码段 //while语句 while (条件): 代码段
GO
//for语句 for 初始化; 条件; 步进; { } //c语言while样式 for 条件 { } //无限循环 for { }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.