1 / 32

程序设计 I 实验

程序设计 I 实验. 中山大学 2013-2014 学年 第 2 学期 教师:刘晓铭 学生: 13 级计科 3 班 + 国防生. 基本安排. 无指定教材 随堂实验 在线编程练习 http://soj.me/course_detail.php?course_id=102. 实验 1 : 编程环境与在线测评系统使用. 实验目的 通过上机解题熟悉编程环境,掌握在线测评系统的使用方法。 编程环境 推荐 Dev-C++ or Visual Studio 2008. 实验内容. 安装编程环境 DEVCPP

aretha
Download Presentation

程序设计 I 实验

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. 程序设计I实验 中山大学 2013-2014学年 第2学期 教师:刘晓铭 学生:13级计科3班+国防生

  2. 基本安排 • 无指定教材 • 随堂实验 • 在线编程练习 http://soj.me/course_detail.php?course_id=102

  3. 实验1: 编程环境与在线测评系统使用 • 实验目的 • 通过上机解题熟悉编程环境,掌握在线测评系统的使用方法。 • 编程环境 推荐Dev-C++ or Visual Studio 2008

  4. 实验内容 • 安装编程环境DEVCPP • 使用网页浏览器打开在线测评系统sicily (http://soj.me),注册帐号,登录后完善帐号信息; • 使用DEVCPP,编写在线系统上指定作业题的对应程序,编译、运行,并观察程序输出 • 在线系统上提交指定的作业题。

  5. 实验环境 • 普通PC机,Windows操作系统,C++编程环境DEVCPP

  6. 实验评测 • 采用在线评测系统sicily (http://soj.me)对提交的代码进行在线实时评测

  7. 作业题1-1 • Problem A+B • Description Your task is to Calculate a + b. • Input The input will consist of a pair of integers a and b, separated by a space in one line. • Output Output a+b in one line. • Sample Input 1 5 • Sample Output 6

  8. 作业1-1参考代码(1) #include <cstdio>using namespace std; int main() {    int a, b;    scanf("%d%d",&a,&b);    printf("%d\n",a+b);    return 0;}

  9. 作业1-1参考代码(2) #include <iostream>using namespace std; int main() {    int a, b;    cin >> a >> b;    cout << a+b << endl;    return 0;}

  10. 参见问题1 Q:编译后运行.exe程序,一闪而过,看不到输出结果? A:加入system(“pause”)语句,使程序退出前暂停。为使用system函数,需包含进头文件cstdlib #include <iostream>#include <cstdlib> using namespace std; int main() {    int a, b;    cin >> a >> b;    cout << a+b << endl;system(“pause”);    return 0;}

  11. 参见问题2 Q:编译错误expected ‘;’ before “return”? #include <iostream>using namespace std; int main() {    int a, b;    cin >> a >> b; cout << a+b << endl    return 0;} A:每条语句要以分号(;)结尾

  12. Dev-C++实验步骤 参考教材“1.10 Developing C++ Programs Using Dev-C++”(p23) (0)运行Dev-C++ (1)创建程序 (2)编辑源代码程序 (3)保存源程序 (4)编译 (5)运行程序

  13. (1)创建文件

  14. (2)编辑源程序代码

  15. (3)编译

  16. (4)运行

  17. Visual C++实验步骤 参考教材“1.9 Developing C++ Programs Using Visual C++”(p17) (0)打开Visual Studio 2008 开始菜单->所有程序->Visual Studio 2008 (1)创建项目 (2)编辑源代码程序 (3)保存源程序 (4)编译 (5)运行程序

  18. (1)创建项目

  19. (2)编辑源程序

  20. (3)保存源程序

  21. (4)编译

  22. (5)运行程序

  23. 结束!

More Related