当前位置:网站首页>Basic operation and process control 2
Basic operation and process control 2
2022-07-03 08:05:00 【Luckyᕙ(⇀‸↼‵‵)ᕗ】
One . Basic operation
( One ). data type
1. Basic data type
a. plastic :byte( byte ) short( Short plastic surgery ) int( plastic ) long( Long plastic surgery )
b. floating-point :float( Single precision ) double( Double precision )
c. Boolean type :bool
d. Character :char
2. Reference data type
string( character string ) Array class Interface
( Two ). Variables and constants
1. Definition
Variable :
a. It refers to the amount that can change at any time during the operation of the program
b. The amount used to store a change A storage unit in memory
c. Access to variable names is access to variable values
d. Each variable is allocated a space to store its own value , And the space occupied by different types is different
Constant :
a. It refers to the variables that will not change during the operation of the program
b. By declaring and initializing Variable when , Add in front const keyword , You can put this Variable Designated as Constant
c. Constants must be initialized at declaration time . After specifying its value , You can't change it any more
d. The value of a constant must be available for calculation at compile time . therefore , You cannot initialize a constant with a value extracted from a variable The amount . If it needs to be done , Read only fields should be used
2. Format
Variable = type + Variable name
Hump nomenclature
3. Type conversion
(1. Transformation types : Implicit 、 mandatory ( Basic types )
a. Implicit : From low to high byte-->short(char)-->int-->long-->float-->double
b. mandatory : From high to low byte<--short(char)<--int<--long<--float<--double
(2). Format :( Force conversion of data types ) Variable name
// Define an integer variable and assign a value , Then it is transformed into a single precision variable
int a = 10;
float b;
b = a;
print(a+"\t"+b); //10
// Define a single precision variable and assign a value , Then it is transformed into a shaping variable
float x = 2.5f;
int y;
y = (int)x;// Forced type conversion
print(y); //2
//ASCII code :char(a:97 A:65)
// Define a character variable and an integer variable and assign values to them , And then do the addition ( The result is an integer or character )
int m = 2, n;
char p = 'd',q;
n = m + p;
print(n); //102
q = (char)(m + p);
print(q); //f
// Define a string variable , Then it is transformed into shaping
string s = "123";
int a = int.Parse(s);// Convert a string into an integer
//Parse Method can convert a string type variable into a basic type variable
4. Console input and output
Console.WriteLine();
Console.ReadLine();
5. Escape character
enter :\n
Horizontal tabs ( When printing multiple variables , The space between them ):\t
( 3、 ... and ). Basic operation
1. + - * / %
use / Do calculations , If there is a floating point in the operand , Then the result must be floating point
2. Relational operator :> >= < <= == !=
3. Self increasing 1:++ Self reduction 1:--
a++ or a-- : Use first and then add and subtract
++a or --a : Add and subtract before using
4. Logical operators :
Logic and :&& The whole is true , False, false
Logic or : || There are really true , All false is false
Logic is not :! 1 change 0 0 change 1
5. Three yuan ( Objective ) Operator :
expression 1? expression 2: expression 3;
int m = 1, n = 2, p;
p = m > n ? 1 : 0;
6.VS Shortcut keys commonly used in
Ctrl + s preservation
Ctrl + c Copy
Ctrl + v Paste
Ctrl + x shear
Ctrl + z revoke
Ctrl + k +d Quick alignment code
Ctrl + k + c Quick comment selection
Ctrl + k + u Quickly cancel the selected comment content
Two . Process control
( One ). The order
Read from top to bottom
( Two ). Judge
1.if
2.switch
( 3、 ... and ). loop
1. for
for( expression 1; expression 2; expression 3) { // Loop body statement }
for The expression of 3 Must be implemented
2. while
expression 1
while( expression 2){ Loop body statement ; expression 3; }
3. do...while
do
{ sentence ; // Execute before judge }
while( The loop condition )
while and while The difference between :
a. Execution order is different
b. When conditions are not met while The loop will not execute once and do while At least once
4.continue
Used inside the loop body , End this cycle , Start a new cycle
5.break
a. Jump out of Switch loop , Carry on switch The following statement Generally used for swile In structure and cyclic structure
b. Terminate a program , Continue to execute the statement after the loop , If there are multiple loops , Just jump out Break This layer of circulation
c. and if Use it together : Meet a certain condition , Jump out of current loop
边栏推荐
- Wechat native applet cloud development learning record 01
- My touch screen production "brief history" 2
- Transplantation of tslib Library
- Unity one click AssetBundle
- C语言-入门-精华版-带你走进编程(一)
- An intern's journey to cnosdb
- The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.
- 使用 FileChannel 进行文件的复制拷贝
- JSON与Object之间转换
- Retail philosophy retail psychological warfare after reading -- 7-11 is a good product!
猜你喜欢
Iterm2 setting
[step on the pit series] MySQL failed to modify the root password
MAE
CLion-Toolchains are not configured Configure Disable profile问题解决
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
Pat class a 1032 sharing
Storage of data
C语言-入门-精华版-带你走进编程(一)
随机推荐
多旅行商问题——公式和求解过程概述
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
[at] abc 258G - Triangle 三元組可達-暴力
Oracle insert single quotation mark
[cocos creator] get the resource UUID
*p++、*++p、++*p、(*p)++
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
Mutual call between Lua and C #
Pulitzer Prize in the field of information graphics - malofiej Award
Unity performance optimization
Screenshot tool snipaste
jsutlis
A tunnel to all ports of the server
Huawei s5700 switch initialization and configuration Telnet, SSH user methods
Ventuz Foundation Series "one step at the door"
PIP uses image website to solve the problem of slow network speed
RM delete file
C language - Introduction - essence Edition - take you into programming (I)
[at] ABC 258g - triple Reach - violence
Getting started with minicom