当前位置:网站首页>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~
边栏推荐
- vscode笔记
- 设置文本向两边居中展示
- 媒体查询、rem移动端适配
- unity 将Text批量替换为TextMeshProUGUI
- 深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
- Detailed explanation of ten solutions across domains (summary)
- Browser Storage WebStorage
- HelloWorld
- selenium学习
- Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"
猜你喜欢
Successful indie developers deal with failure & imposters
Nacos集群搭建
NACOS配置中心设置配置文件
scikit-image图像处理笔记
DisabledDate date picker datePicker
Late night drinking, 50 classic SQL questions, really fragrant~
Teach you simple steps to achieve industrial raspberries pie properly installed RS232 USB drive
transport layer protocol
Mina disconnects and reconnects
One-arm routing experiment and three-layer switch experiment
随机推荐
[issue resolved] - jenkins pipeline checkout timeout
Problems encountered in installing Yolo3 target detection module in Autoware
The future of cloud gaming
The use of three parameters of ref, out, and Params in Unity3D
Quick Start to Drools Rule Engine (1)
设置文本向两边居中展示
DevOps process demo (practical record)
NB-IOT智能云家具项目系列实站
获取预训练模型的网络输入尺寸
LaTeX image captioning text column automatic line wrapping
Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
Browser Storage for H5
深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
document.querySelector()方法
淘宝客APP带自营商城本地生活CPS外卖优惠电影票话费更新渠道跟单生活特权V3
link 和@improt的区别
Network Troubleshooting Basics - Study Notes
云计算基础-学习笔记
el-autocomplete use
D41_buffer pool