第3章简单的c程序设计内容摘要:
ase input a and b: a=12, b=34, a+b = 46 12↙ 遇回车键时结束 34↙ 例 函数 scanf的使用(二) 2020/11/17 21 include main() { int a, b。 printf(Please input a and b:)。 scanf(%2d%2d, amp。 a, amp。 b)。 printf(a=%d, b=%d, a+b=%d\n,a,b,a+b)。 } Please input a and b: a=12, b=34, a+b = 46 1234↙ 遇宽度时结束 例 函数 scanf的使用(三) 2020/11/17 22 include main() { int a, b。 printf(Please input a and b:)。 scanf(%2d%2d, amp。 a, amp。 b)。 printf(a=%d, b=%d, a+b=%d\n,a,b,a+b)。 } Please input a and b: a=12, b=3, a+b = 15 123a↙ 遇非法输入时结束 例 函数 scanf的使用(四) 2020/11/17 23 include main() { int a, b。 printf(Please input a and b:)。 scanf(%d,%d, amp。 a, amp。 b)。 printf(a=%d, b=%d, a+b=%d\n,a,b,a+b)。 } Please input a and b: a=12, b=34, a+b = 46 12,34↙ 这里逗号需要原样输入 例 函数 scanf的使用(五) 2020/11/17 24 include main() { int a, b。 printf(Please input a and b:)。 scanf(%2d%*2d%2d, amp。 a, amp。 b)。 printf(a=%d, b=%d, a+b=%d\n,a,b,a+b)。 } Please input a and b: a=12, b=56, a+b = 68 123456↙ 例 跳过一个输入项 2020/11/17 25 include main() { int a, b。 scanf(%d %d, amp。 a, amp。 b)。 printf(a = %d, b = %d\n, a, b)。 } 问题 1:当要求程序输出结果为 : a = 12, b = 34 时,用户应该如何输入数据。 12 34↙ 例 输入数据的格式控制 2020/11/17 26 include main() { int a, b。 scanf(%d %d, amp。 a, amp。 b)。 printf(a = %d, b = %d\n, a, b)。 } 问题 2:当限定用户输入数据以逗号为分隔符,即输入数据格式为: 12,34↙ 时,应修改程序中的哪条语句。 怎样修改。 scanf(%d,%d, amp。 a, amp。 b)。 例 输入数据的格式控制 2020/11/17 27 include main() { int a, b。 scanf(%d %d, amp。 a, amp。 b)。 printf(a = %d, b = %d\n, a, b)。 } 问题 3:语句 scanf(%d %d, amp。 a, amp。 b)。 修改为scanf(a = %d, b = %d, amp。 a, amp。 b)。 时,用户应该如何输入数据。 a = 12, b = 34↙ 例 输入数据的格式控制 2020/11/17 28 include main() { int a, b。 scanf(%d %d, amp。 a, amp。 b)。 printf(a = %d, b = %d\n, a, b)。 } 问题 4:限定用户输入数据为以下格式为 1234↙ 同时要求程序输出结果为 a。第3章简单的c程序设计
本资源仅提供20页预览,下载后可查看全文
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。
相关推荐
第3章:变量、数据类型和表达式
char byte sbyte或 char short sbyte、 byte、 ushort、 uint、 ulong或 char ushort sbyte、 byte、 short或 char int sbyte、 byte、 short、 ushort、 uint、 ulong或 char uint sbyte、 byte、 short、 ushort、 int或 char long
第3章选址规划与生产过程组织
北京科技大学经济管理学院 杨建华 • 设施布置前需要考虑的问题 ? • 自制还是外购(转包) ? – 可用生产能力 – 专有技术 – 质量考虑 – 需求 – 成本 设施布置 Layout Design 北京科技大学经济管理学院 杨建华 麦当劳的后台 /前台设施布置考虑因素 北京科技大学经济管理学院 杨建华 北京科技大学经济管理学院 杨建华 北京科技大学经济管理学院 杨建华