当前位置:网站首页>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~
边栏推荐
- 深夜小酌,50道经典SQL题,真香~
- Cocos Creator Mini Game Case "Stick Soldier"
- vs2017关于函数命名方面的注意事项
- Next-Generation Parsing Technology - Cloud Parsing
- 单片机期末复习大题
- el-progress implements different colors of the progress bar
- Browser Storage WebStorage
- unity 将Text批量替换为TextMeshProUGUI
- 花花省V5淘宝客APP源码无加密社交电商自营商城系统带抖音接口
- 七种让盒子水平垂直居中的方法
猜你喜欢
随机推荐
## 简讲protobuf-从原理到使用
Pytorch分布式并行处理
跨域的十种解决方案详解(总结)
网络协议基础-学习笔记
Four ways to obtain Class objects through reflection
自营商城提高用户留存小技巧,商城对接小游戏分享
人人AI(吴恩达系列)
D39_Vector
What is the website ICP record?
Billions of IT operations in the market, the product by strength to speak
Late night drinking, 50 classic SQL questions, really fragrant~
NB-IOT智能云家具项目系列实站
记录vue-页面缓存问题
Transformer interprets and predicts instance records in detail
无法导入torchvision.io.read_image
VS Code私有服务器部署(私有化)
文件内音频的时长统计并生成csv文件
Nacos集群搭建
LeetCode中常用语言的一些基本方法记录
link 和@improt的区别