词条 | indent |
释义 | indent n. 缩进, 契约, 订货单, 凹痕vi. 切割成锯齿状vt. (印刷, 书写)缩排, 定货, 印凹痕习惯用语indent upon sb. for sth. 向某人订购某物indent on sb. for sth. 向某人订购某物GNU Indent 代码格式化工具 可以将混乱的、没有格式的代码按照你所设置的参数进行格式化,有助于统一格式。 例如,一个没有缩进的源代码: #include <stdio.h>#include <stdlib.h>#include <time.h>int main(void){char gesture[3][10]={"scissor","stone","cloth"};int man,computer,result, ret;srand(time(NULL));while(1){computer=rand()%3;printf("\Input your gesture (0-scissor 1-stone 2-cloth):\");ret=scanf("%d",&man);if(ret!=1||man<0||man>2){printf("Invalid input!\");return 1;}printf("Your gesture: %s\\tComputer's gesture: %s\",gesture[man],gesture[computer]);result=(man-computer+4)%3-1;if(result>0)printf("You win!\");else if(result==0)printf("Draw!\");else printf("You lose!\");}return 0;}使用indent -kr -i8 test.c格式化后,将变为这样: #include <stdio.h>#include <stdlib.h>#include <time.h>int main(void){ char gesture[3][10] = { "scissor", "stone", "cloth" }; int man, computer, result, ret; srand(time(NULL)); while (1) { computer = rand() % 3; printf ("\Input your gesture (0-scissor 1-stone 2-cloth):\"); ret = scanf("%d", &man); if (ret != 1 || man < 0 || man > 2) { printf("Invalid input!\"); return 1; } printf("Your gesture: %s\\tComputer's gesture: %s\", gesture[man], gesture[computer]); result = (man - computer + 4) % 3 - 1; if (result > 0) printf("You win!\"); else if (result == 0) printf("Draw!\"); else printf("You lose!\"); } return 0;} |
随便看 |
百科全书收录594082条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。