Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic programming specification of C language?

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What is the basic programming specification of C language? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

What is C language? C language is a process-oriented and abstract general programming language, which is widely used in low-level development. C language can be used to compile and process low-level memory in a simple way.

Basic compilation specification

The norm is a kind of stipulation, it is a kind of artificial, the agreement becomes the custom, even if does not follow that kind of stipulation, this kind of stipulation will not be wrong, this kind of stipulation is called the norm. Although we do not follow the specification and will not make mistakes, but then the code will be very messy. If you form a very bad habit of writing code, the code will be written in a mess, and when you have a job interview in the future, this habit may cost you the opportunity.

First, the benefits of code standardization

It looks neat and comfortable, logical and organized. If you write 10,000 lines of code in a non-standard way now, you can read it now, but it will be very difficult for you to look back after three months, let alone show it to others. So the code has to write specifications. Standard code is not easy to make the program error, even if something goes wrong, it will be very convenient to check it. If you enter the code in a non-standard format, it is easy to make mistakes. Although the format does not affect the functionality of the program, it does affect readability. The format of the program is clear and beautiful, and it is an important element of the program style.

Standard code

Joseph's ring

# include # define N 100int main () {int njjjn: total number, m: report numerical value, s commencing number scanf ("% d", & n); int a [N] = {0}; / / array initialization int iJJ; for (I = 0; I)

< n; i++) //数组遍历 { a[i] = i+1; //i是数组的位置量,a[i]是每个人的原始编号(从1开始) } i=s-1; //数组的起点(0) while (n >

1) {I = (i+m-1)% n; / / the position of the person out of the circle in the array for (j = iTun1; j

< n; j++) { a[j-1] = a[j]; } n--; //出局1人后,总人数-1 if(i == n) //终点后,开始起点(围成一个圈) { i = 0; } } printf("%d\n", a[i]); //输出留下的人的原始编号 return 0;} 不规范的代码 #includeint main(void){int n,u,d,s,t;s=0;t=0;scanf("%d%d%d",&n,&u,&d);if(u>

= n) printf ("1"); else {do (s > = n) break;else (s > = n) while (s) printf ("1"); else {do (s > = n) break;else (s > = n) break;else (s > = =, +, +, -, *, /,%, &, & &, |, etc., a space should be added before and after the binocular operator.

Note that there is no space before and after the "%" in% d.

Rule 6: unary operators!, ~, + +, -, -, *, &, etc., without spaces.

Rule 7: such operators as array symbol [], structure member operator., point to structure member operator->, do not add spaces before and after.

Rule 8: for for and if statements with long expressions, some spaces can be removed appropriately for the sake of compactness. However, the spaces immediately following for and if cannot be deleted, and the statements that follow them can remove some spaces appropriately according to the length of the statement. For example:

For (iTuno; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report