当前位置:网站首页>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~
边栏推荐
- el-progress implements different colors of the progress bar
- [Problem has been resolved]-Virtual machine error contains a file system with errors check forced
- DevOps流程demo(实操记录)
- [ingress]-ingress exposes services using tcp port
- product learning materials
- Pytorch分布式并行处理
- Seven Ways to Center a Box Horizontally and Vertically
- Cocos Creator Mini Game Case "Stick Soldier"
- Complete mysql offline installation in 5 minutes
- Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
猜你喜欢
随机推荐
Media query, rem mobile terminal adaptation
Transformer interprets and predicts instance records in detail
Into the pre-service, thought they play so flowers
白鹭egret添加新页面教程,如何添加新页面
VSCode编写OpenCV
input detailed file upload
Nacos配置服务的源码解析(全)
前置++和后置++的区别
unity 将Text批量替换为TextMeshProUGUI
Collision, character controller, Cloth components (cloth), joints in the Unity physics engine
GetEnumerator method and MoveNext and Reset methods in Unity
Difference between link and @improt
Late night drinking, 50 classic SQL questions, really fragrant~
NB-IOT智能云家具项目系列实站
Browser Storage for H5
Take you in-depth understanding of cookies
Nacos集群搭建
D39_ coordinate transformation
Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
document.querySelector()方法