ChC语言基础实用学习教案_第1页
ChC语言基础实用学习教案_第2页
ChC语言基础实用学习教案_第3页
ChC语言基础实用学习教案_第4页
ChC语言基础实用学习教案_第5页
已阅读5页,还剩65页未读 继续免费阅读

下载本文档

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

文档简介

1、会计学1ChC语言基础语言基础(jch)实用实用第一页,共70页。第2页/共70页第1页/共70页第二页,共70页。第3页/共70页第2页/共70页第三页,共70页。第4页/共70页第3页/共70页第四页,共70页。第5页/共70页第4页/共70页第五页,共70页。正确不正确smart5smart(不能数字开头)_decisionbomb?(有非法字符?)key_boardkey.board(有非法字符.)第6页/共70页第5页/共70页第六页,共70页。第7页/共70页第6页/共70页第七页,共70页。第8页/共70页第7页/共70页第八页,共70页。第9页/共70页第8页/共70页第九页,

2、共70页。asmdefaultfloatoperatorstatic_castunionautodeleteforprivatestructunsignedbooldofriendprotectedswitchusingbreakdoublegotopublictemplatevirtualcasedynamic_castifregisterthisvoidcatchelseinlinereinterpret_castthrowvolatilecharenumintreturntruewchar_tclassexplicitlongshorttrywhileconstexportmutable

3、signedtypedef. const_castexternnamespacesizeoftypeid. . Continuefalsenewstatictypename. . 第10页/共70页第9页/共70页第十页,共70页。第11页/共70页第10页/共70页第十一页,共70页。第12页/共70页第11页/共70页第十二页,共70页。第13页/共70页第12页/共70页第十三页,共70页。类型名类型字节表示范围char字符型1-128 127unsigned char无符号字符型10 255signed char有符号字符型(与字符型相同)1-128 127int整型*与机器有关uns

4、igned int无符号整型*与机器有关signed int有符号整型(与整型相同)*与机器有关short int短整型2-32,768 32,767unsigned short int 无符号短整型2065,535signed short int有符号短整型(与短整型相同)2-32,768 32,767long int长整型4-2,147,483,648 2,147,483,647signed long int有符号长整型(与长整型相同)4-2,147,483,648 2,147,483,647unsigned long int无符号长整型404,294,967,295float浮点型43.

5、4E +/- 38 (7位有效数字)double双精度型81.7E +/- 308 (15位有效数字)long double长双精度型101.2E +/- 4932 (19位有效数字)第14页/共70页第13页/共70页第十四页,共70页。第15页/共70页第14页/共70页第十五页,共70页。第16页/共70页第15页/共70页第十六页,共70页。第17页/共70页第16页/共70页第十七页,共70页。从到方法charshort符号位扩展charlong符号位扩展charunsigned char最高位失去符号位意义,变为数据位charunsigned short符号位扩展到short;然后

6、从short转到 unsigned shortcharunsigned long符号位扩展到long; 然后从long 转到unsigned longcharfloat符号位扩展到long; 然后从long 转到floatchardouble符号位扩展到long; 然后从long 转到doublecharlong double符号位扩展到long; 然后从long 转到long doubleshortchar保留低位字节shortlong符号位扩展shortunsigned char保留低位字节shortunsigned short最高位失去符号位意义,变为数据位shortunsigned l

7、ong符号位扩展到long; 然后从long转到unsigned doubleshortfloat符号位扩展到long; 然后从long 转到floatshortdouble符号位扩展到long; 然后从long 转到doubleshortlong double符号位扩展到long; 然后从long 转到doublelongchar保留低位字节longshort保留低位字节longunsigned char保留低位字节longunsigned short保留低位字节longunsigned long最高位失去符号位意义,变为数据位longFloat使用单精度浮点数表示。可能丢失精度。longd

8、ouble使用双精度浮点数表示。可能丢失精度。longlong double使用双精度浮点数表示。可能丢失精度。第18页/共70页第17页/共70页第十八页,共70页。从到方法unsignedcharchar最高位作为符号位unsigned charshort0扩展unsigned charlong0扩展unsigned charunsigned short0扩展unsigned charunsigned long0扩展unsigned charfloat转换到long; 再从 long 转换到floatunsigned chardouble转换到long; 再从 long 转换到double

9、unsigned charlong double转换到long; 再从 long 转换到doubleunsigned shortchar保留低位字节unsigned shortshort最高位作为符号位unsigned shortlong0扩展unsigned shortunsigned char保留低位字节unsigned shortunsigned long0扩展unsigned shortfloat转换到long; 再从 long 转换到floatunsigned shortdouble转换到long; 再从 long 转换到doubleunsigned shortlong double

10、转换到long; 再从 long 转换到doubleunsigned longchar保留低位字节unsigned longshort保留低位字节unsigned longlong最高位作为符号位unsigned longunsigned char保留低位字节unsigned longunsigned short保留低位字节unsigned longfloat转换到long; 再从 long 转换到floatunsigned longdoubleConvert directly to doubleunsigned longlong double转换到long; 再从 long 转换到doubl

11、e第19页/共70页第18页/共70页第十九页,共70页。第20页/共70页第19页/共70页第二十页,共70页。第21页/共70页第20页/共70页第二十一页,共70页。第22页/共70页第21页/共70页第二十二页,共70页。5 cout Weekly Pay = weeklyPay n;第23页/共70页第22页/共70页第二十三页,共70页。第24页/共70页第23页/共70页第二十四页,共70页。第25页/共70页第24页/共70页第二十五页,共70页。1984L1984l1984U1984u1984LU1984lu第26页/共70页第25页/共70页第二十六页,共70页。第27页/

12、共70页第26页/共70页第二十七页,共70页。被处理为long double型。1984L1984l1984U1984u1984LU1984lu第28页/共70页第27页/共70页第二十八页,共70页。类型字节数有效位(十进制)指数长度 尾数长度float4678bits23bitsdouble8151611bits52bits第29页/共70页第28页/共70页第二十九页,共70页。第30页/共70页第29页/共70页第三十页,共70页。第31页/共70页第30页/共70页第三十一页,共70页。第32页/共70页第31页/共70页第三十二页,共70页。第33页/共70页第32页/共70页第

13、三十三页,共70页。第34页/共70页第33页/共70页第三十四页,共70页。第35页/共70页第34页/共70页第三十五页,共70页。第36页/共70页第35页/共70页第三十六页,共70页。NametAddresstTelephone“ASCII character 65: 101“Example to show the use of backslash for writing a long string“Example to show the use of backslash for writing a long string第37页/共70页第36页/共70页第三十七页,共70页。第3

14、8页/共70页第37页/共70页第三十八页,共70页。第39页/共70页第38页/共70页第三十九页,共70页。第40页/共70页第39页/共70页第四十页,共70页。第41页/共70页第40页/共70页第四十一页,共70页。第42页/共70页第41页/共70页第四十二页,共70页。圆周长变量cout radius;area = PI*radius*radius;circumference = 2.0*PI*radius;cout Area of circle of radius radius is area n;cout and its circumference is circumfere

15、nce n;第43页/共70页第42页/共70页第四十三页,共70页。第44页/共70页第43页/共70页第四十四页,共70页。第45页/共70页第44页/共70页第四十五页,共70页。第46页/共70页第45页/共70页第四十六页,共70页。第47页/共70页第46页/共70页第四十七页,共70页。第48页/共70页第47页/共70页第四十八页,共70页。当枚举类型中的某个成员赋值后,其后的成员则按依次加1的规则确定其值。第49页/共70页第48页/共70页第四十九页,共70页。第50页/共70页第49页/共70页第五十页,共70页。eBLUE=6、Eyellow=7、Eburgundy=4

16、1第51页/共70页第50页/共70页第五十一页,共70页。第52页/共70页第51页/共70页第五十二页,共70页。第53页/共70页第52页/共70页第五十三页,共70页。第54页/共70页第53页/共70页第五十四页,共70页。第55页/共70页第54页/共70页第五十五页,共70页。第56页/共70页第55页/共70页第五十六页,共70页。第57页/共70页第56页/共70页第五十七页,共70页。第58页/共70页第57页/共70页第五十八页,共70页。第59页/共70页第58页/共70页第五十九页,共70页。第60页/共70页第59页/共70页第六十页,共70页。Today is T

17、hursdayPress any key to continue 第61页/共70页第60页/共70页第六十一页,共70页。说明符类型%wdint 或char w = 宽度%w.dfdouble w = 总的宽度(包括小数点) d = 小数位数 %wcchar 或int w = 宽度 %wschar * (字符串) 格式 w = 宽度 %wuunsigned int w = 宽度 %wo八进制 %wx十六进制%m.ddddddexx %m.ddddddExx %m.ddddddgxx %m.ddddddGxx指数记数法第62页/共70页第61页/共70页第六十二页,共70页。变量说明int x

18、 = 98;float y = 1.34567889; char letter = A; char word = Hello;语句printf(Default formats: %d %f %c %sn, x,y,letter,word); 结果Default formats: 98 1.345679 A Hello 格式说明语句printf(Width specified: %5d %10.4f %5c %10sn, x,y,letter,word);结果Width specified: 98 1.3457 A Hello打印内存地址语句printf(Address of x: %u Add

19、ress of y: %un, &x, &y);结果Address of x: 4026528400 Address of y: 4026528396 字符的ASCII 值语句printf(Ascii value of letter: %dn, letter); 结果Ascii value of letter: 65与整数等价的字符语句printf(Character equivalent of x: %cn, x); 结果Character equivalent of x: b 与整数等价的八进制数语句 printf(Octal equivalent of x: %on, x); 结果 Octal equivalent of x: 142 与整数等价的十六进制数语句printf(Hexadecimal equivalent of x: %xn, x);结果Hexadecimal equivalent of x: 62第63页/共70页第62页/共70页第六十三页,共70页。第64页/共70页第63页/共70页第六十四页,共70页。转换字符类型含义Cint输出一个字符Cint同上Dint输出有符号十进制整

温馨提示

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

评论

0/150

提交评论