当前位置:网站首页>Standard C language summary 4
Standard C language summary 4
2022-07-28 07:07:00 【c7473168】
Labyrinth :
Data analysis :
1. Define a two-dimensional character array as a maze map
2. Define the location of the variable record role x y
3. Time :time(NULL) obtain 1970-1-1 The total number of seconds passed by the runtime
logic analysis :
Into the dead cycle :
1. Show map
2. Get the direction key and process it
Judge whether the road ahead ' '
If it is :
1. Turn the old location into ' '
2. Turn the new location into '@'
3. Update character position coordinates x y
3. Determine whether to reach the exit
If it is : Program end
tuixiangzi : Data analysis :
1. Determine the correspondence between numeric values and characters
0 ' '
1 '@'
2 '$'
3 '#'
4 'o'
5 '@'
7 '$'
2. Definition 8*8 Integer map and initialize
3. Define variables that record the position of the role x y
4. Variables that define the number of recording steps
logic analysis : Into the dead cycle
1. Clean the screen , Show map
if(0 == map[i][j]) printf(" ");
2. Get the direction key and process it
3. Determine whether the game wins
The road ahead , Refer to maze
In front of the +1
Original location -1
Update coordinates
2. In front is the box
In front of the box is the road \ The target point
In front of people +3
In front of people -3+1
Man's original position -1
' Update left
Decimal to binary :( Convert to other base )
Remainder method : use 2 Balance the data , Then continue to seek surplus from the business , Until Shang Wei 0 end , The remainder generated in this process is the binary of the data ( The reverse )
Right seeking method :
From high position to position , data 2^(n-1) If it's enough , So the first n Bit is 1, Otherwise, it would be 0, Until the data is reduced to 0
Binary to decimal : ( Other decimal system to decimal system m^(n-1))
Everyone's 2^(n-1) Sum up
C In language , With 0 The starting number is octal , With 0x The first number is hexadecimal
Original code : Binary of data
Inverse code :
The inverse code of a positive number is his original code
The inverse code of a negative number is its original code except for the sign bit , Other bits are inversed bit by bit
Complement code :
The complement of a positive number is its original code
The complement of a negative number is its inverse +1
Complement to data :
Unsigned complement is directly converted to decimal
The highest sign is 0, The description is positive , It is also directly converted to decimal
Signed and the highest bit is 1;
An operator & | ~ ^ << >>
A & B Press phase and Different for 0
A | B Press bit or Different for 1
~A Reverse by position
A ^ B Bitwise XOR Same as 0, Dissimilarity is 1
A << n hold A The complement of moves to the left n position , Left discard , The right to repair 0
A >> n hold A The complement of moves to the right n position , On the right side of the discarded , Fill in the sign on the left , The highest bit is 1 Time compensation 1, by 0 repair 0
Custom function
To better manage your own code , Reduce the redundancy of the code and encapsulate the code into a functional form
Function declaration :
Implicitly declare : When the function is called , There is no previous declaration or definition of this function
An implicit warning will be generated , Parameters will be guessed based on actual parameters ,
The return value will be guessed as int Type should not generate implicit declarations anyway
As long as there is a declaration or definition before the call
The purpose of function declaration is to tell other code the calling format of the function
return type Function name ( type 1 The name of the parameter 1, type 2 The name of the parameter 2,...);
Be careful :
1, There is a function definition before the function call , Then the function declaration can be omitted
2, The return value of the function will be returned at the call location , Can be displayed immediately ,
You can also use variables to record
3, A function is recommended not to exceed 50 Line code
边栏推荐
猜你喜欢

MOOC Weng Kai C language week 6: arrays and functions: 1. Arrays 2. Definition and use of functions 3. Parameters and variables of functions 4. Two dimensional arrays

DHCP principle and configuration

RAID disk array

根据excel生成create建表SQL语句

About gcc:multiple definition of

Custom component -- communication between parent and child components

Joern的代码使用-devign

win下安装nessus

MOOC翁恺C语言第七周:数组运算:1.数组运算2.搜索3.排序初步

防火墙——iptables防火墙(四表五链、防火墙配置方法、匹配规则详解)
随机推荐
Starting point Chinese website font anti crawling technology web page can display numbers and letters, and the web page code is garbled or blank
VSphere esxi 7.0 update 3 release notes
[learning notes] VIM editor
DOM - Events
Remotely access the local website of services such as neo4j on the ECS
组管理和权限管理
shell---sed语句练习
Shell script - regular expression
DOM Foundation
Applets: WSX scripts
Svg understanding and drawing application
Shell--第一天作业
Small turtle C (Chapter 6 arrays 1 and 2)
小甲鱼C(第五章循环控制结构程序567)break和continue语句
My deployment notes
Custom components -- styles
Forward and backward slash notes
Applet creation component
Uni app double click event simulation
视频格式基础知识:让你了解MKV、MP4、H.265、码率、色深等等