C语言代码风格_第1页
C语言代码风格_第2页
C语言代码风格_第3页
C语言代码风格_第4页
C语言代码风格_第5页
已阅读5页,还剩85页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、234567void void Function(intFunction(int x) x) / / program code code void void Function(intFunction(int x) x) / / program code code if (condition)if (condition) / / program code code elseelse / / program code code if (condition)if (condition) / / program code code else else / / program code code for

2、 (initialization; condition; for (initialization; condition; update)update) / / program code code for (initialization; condition; for (initialization; condition; update)update) / / program code code while (condition)while (condition) / / program code code while (condition)while (condition) / / progr

3、am code code 如果出现嵌套的,则使用缩进对齐如果出现嵌套的,则使用缩进对齐,如:,如: 8910/ 空行空行void Function1() / 空行空行void Function2() / 空行空行void Function3() / 空行空行while (condition)statement1;/ 空行空行if (condition) statement2;elsestatement3;/ 空行空行statement4; 1112void Func1(int x, int y, int z); / 良好的风格良好的风格void Func1 (int x,int y,int z

4、); / 不良的风格不良的风格printf(%d%d%d, a, b, c); / 良好的风格良好的风格printf(%d%d%d,a,b,c); / 不良的风格不良的风格if (year = 2000) / 良好的风格良好的风格if(year=2000) / 不良的风格不良的风格if (a=b) & (c=b&c=d) / 不良的风格不良的风格for (i=0; i10; i+) / 良好的风格良好的风格for(i=0;i10;i+) / 不良的风格不良的风格for (i = 0; i 10; i +) / 过多的空格过多的空格x = a b ? a : b; / 良好的风格

5、良好的风格x=aFunction(); / 不要写成不要写成 b - Function();1314intint width; width;/ / 宽度宽度intint height; height;/ / 高度高度intint depth; depth;/ / 深度深度intint width, height, depth; / width, height, depth; /宽度高度深度宽度高度深度x = a + b;x = a + b;y = c + d;y = c + d;z = e + f;z = e + f;x =x = a + b; y = c + d; z = e + f;a +

6、 b; y = c + d; z = e + f;if (width height) if (width height) dosomethingdosomething();(); if (width height) if (width height) dosomethingdosomething();();for (initialization; condition; for (initialization; condition; update)update) dosomethingdosomething();(); / / 空行空行other();other();for (initialization; condition; update)for (initialization; condition; update) dosomethingdosomething();();other();other();1516171819202122232425262728293031323334353637383940414243当只允许函数访问地址内容,不允许修改当只允许函数访问地址内容,不允许修改时,可以把函数的指针参数定义为时,可以把函数的

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论