1 / 10

程序设计入门

程序设计入门. 卓 越 2012 年 6 月 30 日. 学习目标. 熟悉 C 语言程序的编译和运行 掌握整数和浮点数的输入输出 掌握 64 位整数的输入输出 掌握变量交换的三变量法 了解 Online Judge 对程序的要求. Code::Blocks. 下载地址: http://219.224.30.70/rj/ 编译、运行和调试 注意:路径中不要包含中文. 浮点数的输入输出. 变量类型转换 整数 / 整数 = 整数,浮点数 / 整数 = 浮点数 输入 double a; scanf(“%lf”, &a); 输出

Download Presentation

程序设计入门

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 程序设计入门 卓 越 2012年6月30日

  2. 学习目标 • 熟悉C语言程序的编译和运行 • 掌握整数和浮点数的输入输出 • 掌握64位整数的输入输出 • 掌握变量交换的三变量法 • 了解Online Judge对程序的要求

  3. Code::Blocks • 下载地址:http://219.224.30.70/rj/ • 编译、运行和调试 • 注意:路径中不要包含中文

  4. 浮点数的输入输出 • 变量类型转换 • 整数/整数=整数,浮点数/整数=浮点数 • 输入 double a; scanf(“%lf”, &a); • 输出 printf(“%f\n”, a / 5);

  5. 浮点数判等 double a, b; double eps = 1e-6; • 等于 fabs(a – b) < eps • 大于 a > b + eps • 小于 a < b – eps • 大于等于 a > b + eps • 小于等于 a < b + eps

  6. 64位整数 • 表示范围-2^63~2^63-1 • 输入输出的格式与平台和编译器相关 long long a; scanf(“%lld”, &a); printf(“%lld\n”, &a); or scanf(“%I64d”, &a); printf(“%I64d\n”, &a);

  7. 交换变量 • 三变量法(推荐) t = a; a = b; b = t; • 二变量法? a = a + b; b = a – b; a = a – b; a ^= b ^= a ^= b;

  8. Online Judge (OJ) • BNUOJ: http://acm.bnu.edu.cn/ • 判题原则:在规定时间和空间内,输出正确的结果 • 注意: • 严格按照题目要求的输出格式 • 不要多余的提示信息

  9. 打表 • 合理利用OJ的规则,在时间允许的情况下用一个程序输出所有的答案,再另写一个程序提交答案 • 例:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=4058

  10. The End Thanks!

More Related