当前位置:网站首页>Tips for formatting code indentation
Tips for formatting code indentation
2022-08-05 06:44:00 【ProfSnail】
In recent days, I have often been in the Q&A section to answer questions, and found a little problem.
The code that some friends put up when they ask questions is not indented; or the programming format is not very beautiful, and they are often fascinated by it.
The brother who asked the question quickly put a piece of code because he was in a hurry.
I am here to help him answer questions, looking at the code, I am quite anxious.Today, I accidentally discovered a piece of unindented code, just to share a wave of questions.
I simply take a small program in C language that I have helped deal with in the past two days as an example.I changed it to unindented format.
BTree createTree(char s[]) {BTNode *p;BTNode *rt;BTNode *lchild, *rchild, parent;stack S;p = (BTNode * )malloc(sizeof(BTNode));p->lchild = NULL;p->rchild = NULL;p->data = s[0];S.push§;rt = p;for(int i = 1; s[i] != '\0';i++){if('A' <= s[i] && s[i] <= 'Z') {p = (Node ) malloc(sizeof(Node));p->data = s[i];p->lchild = NULL;p->rchild = NULL;S.pop();S.push§;}if(s[i] == '(') {S.push(NULL);}if(s[i] == ',') {S.push(NULL);}if(s[i] == ')') {rchild = S.top();S.pop();lchild =S.top();S.pop();parent = S.top();S.pop();parent->lchild = lchild;parent->rchild = rchild;S.push(parent);}}returnrt;}
This code doesn't really want to be bothered by looking at it, but let's think about it.The best way is to copy this code and paste it into Visual Studio.
But for all the code without blank lines, VS can't handle it.It needs to be processed with Sublime Text first.
Sublime Text Ctrl + H to bring up the replacement interface.Search for semicolons and replace all semicolons with a semicolon plus a newline (the newline can be typed out with Ctrl+Enter).
Next, copy the code in SublimeText into VisualStudio, and VisualStudio will help with indentation and parentheses.
You're done!
How do you deal with this situation?Welcome to discuss~
边栏推荐
- HelloWorld
- Met with the browser page
- 大小屏适配
- Nacos集群的搭建过程详解
- 图像处理、分析与机器视觉一书纠错笔记
- scikit-image图像处理笔记
- Some basic method records of commonly used languages in LeetCode
- 多行文本省略
- From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
- 邮件管理 过滤邮件
猜你喜欢

Collision, character controller, Cloth components (cloth), joints in the Unity physics engine

数组&的运算

Mina's long and short connections
![[Problem has been resolved]-Virtual machine error contains a file system with errors check forced](/img/07/1222a44dd52b359bf7873e6f3b7ebf.png)
[Problem has been resolved]-Virtual machine error contains a file system with errors check forced

Introduction to Network Layer Protocols

NACOS Configuration Center Settings Profile

LaTeX 图片加标题 文本分栏自动换行

单片机原理与应用复习

Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"

HelloWorld
随机推荐
人人AI(吴恩达系列)
VS Code私有服务器部署(私有化)
numpy.random使用文档
Email management Filter emails
The use of three parameters of ref, out, and Params in Unity3D
Nacos集群搭建
UI刘海屏适配方式
系统基础-学习笔记(一些命令记录)
Chengyun Technology was invited to attend the 2022 Alibaba Cloud Partner Conference and won the "Gathering Strength and Going Far" Award
Transformer interprets and predicts instance records in detail
错误记录集锦(遇到则记下)
七种让盒子水平垂直居中的方法
selenium学习
VRRP overview and experiment
D39_Eulerian Angles and Quaternions
Some basic method records of commonly used languages in LeetCode
What is Alibaba Cloud Express Beauty Station?
config.js相关配置汇总
Cloud Computing Basics - Study Notes
LaTeX使用frame制作PPT图片没有标号