- 1、本文档共35页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ch10 Formatted InputOutput
Chapter 10 - Formatted Input/Output 10.1 Introduction In this chapter Presentation of results scanf and printf Streams (input and output) gets, puts, getchar, putchar (in stdio.h) 10.2 Streams Streams Sequences of characters organized into lines Each line consists of zero or more characters and ends with newline character ANSI C must support lines of at least 254 characters Performs all input and output Can often be redirected Standard input – keyboard Standard output – screen Standard error – screen More Chapter 11 10.3 Formatting Output with printf printf Precise output formatting Conversion specifications: flags, field widths, precisions, etc. Can perform rounding, aligning columns, right/left justification, inserting literal characters, exponential format, hexadecimal format, and fixed width and precision Format printf( format-control-string, other-arguments ); Format control string: describes output format Other-arguments: correspond to each conversion specification in format-control-string Each specification begins with a percent sign(%), ends with conversion specifier printf 库函数 格式化输出函数 printf(格式控制, 输出变量列表); 格式控制:用双引号括起来的字符串 格式说明 = % + 格式字符 将输出列表中的对应数据转换成指定格式输出 普通字符:除格式说明外的其他字符,原样输出 输出列表:需要输出的一些数据,可以是变量或表达式 例1: #include stdio.h void main( ) { int r = 50 ; float area = 3.5; printf(r = %d, area = %f, r, area); } /*输出结果:r = 50, area = 3.500000 */ 10.4 Printing Integers Integer Whole number (no decimal point): 25, 0, -9 Positive, negative, or zero Only minus sign prints by default (later we shall change this) 1. Print Program Output 10.5 Printing Floating-Point Numbers Floating Point Numbers Have a decimal point (33.5) Exponential notation (computers version of scientific notation) 150.3 is 1.503 x 102 in scientific 150.3 is 1.503E+02 in exponential (E stands for exponent) use e or E f – print floating point with at least one digit to left of decimal g (or G) - prints in f or e with no trailing zeros (1.2300 becomes 1.23) Use exponential
您可能关注的文档
最近下载
- 13G311-1 混凝土结构加固构造.docx VIP
- 2025春《中考解读 化学》(广东版)课件 专题1 化学与五育.pptx
- PCB工程师笔试题-附答案.doc
- JBT 8816-2015 工程机械 驱动桥 技术条件.docx VIP
- 钢铁冶炼技术基础知识单选题100道及答案解析.docx VIP
- 【艺考生】高中数学基础知识默写课件 04 三角函数与解三角形.pdf VIP
- 2025大象版(2024)小学科学一年级下册第一单元 水《2 运水比赛》教学设计.docx VIP
- 股骨头缺血性坏死护理常规及健康教育.docx VIP
- 部编版道德与法治八年级下册每课教学反思.pdf VIP
- XX河流域水环境综合治理项目可行性研究报告.docx
文档评论(0)