483
备注:
|
4812
|
删除的内容标记成这样。 | 加入的内容标记成这样。 |
行号 1: | 行号 1: |
= 实验要求 = | [[TableOfContents]] = 实验基本要求 = |
行号 7: | 行号 8: |
= 实验1 = | = 实验运行环境简介 = |
行号 9: | 行号 10: |
== DEV-C++集成开发环境 == 安装运行 1. 下载安装程序: http://www.bloodshed.net/dev/devcpp.html 1. 运行安装程序进行安装 1. 运行集成开发环境:开始菜单=〉Bloodshed Dev-C++ =〉Dev-C++ 工程创建 1. 在Dev-C++菜单中选择File=>New=>Project 1. 在弹出对话框中选择Console Application,选中C Project,Name框输入一个工程名字,最后按OK按钮 1. 选择硬盘上某个路径保存你所建立的工程 程序运行 1. 选择菜单Execute=>Compile编译程序 1. 如果编译没有错误,选择Execute=>Run运行程序,得到运行结果 如果程序结果一闪而过,怎么办? * 在命令行窗口中运行可执行程序 * 在代码中添加:system("PAUSE");一行使程序暂停(system函数在stdlib.h中定义) 调试程序 * 启动调试 选择菜单Debug=>Debug * 设置断点 将光标移动到需要设置断点的行,选择Debug=>Toggle Breakpoint * 单步执行 菜单Debug=>Next Step和Step Into * 查看变量 菜单Debug=>Add Watch == Visual Studio.Net 2003集成开发环境 == 创建工程 1. 打开Visual Studio.net 2003集成开发环境 1. 菜单File=>New=>Project 1. 在弹出的对话框中:Project Types选择Visual C++ Projects,Templates选择Win32 Console Application,Name中输入工程名称,Location选择保存的路径。最后点OK 1. 在接下来的工程向导中,选择Application Settings,选择Empty Project,最后按Finish 1. 菜单View=>Solution Explorer 1. 在Solution Explorer中选中刚才建立的工程 1. 菜单File=>Add New Item 1. 在弹出的对话框中:Categories选择Visual C++,Templates选择C++ File,Name中输入文件名,文件要以.c结尾,最后按Open。 编译运行 1. 菜单Build=>Build Solution 1. 如果编译通过,选择菜单Debug=>Start Without Debugging 调试 * 开始调试:菜单Debug=>Start * 设置断点:光标移动到要设置断点的地方,按F9 * 单步执行:Debug菜单下的Step Into和Step Over * 查看变量:Debug菜单下的Quick Watch = 实验1-1 = == 实验目的 == 熟悉C语言开发环境,学会 * 创建工程 * 编辑代码 * 编译连接,生成可执行程序 * 调试代码 == 实验内容 == 编译运行以下程序,观察程序运行的结果 完成课后作业1-1 {{{#!cplusplus #include <stdio.h> main() { printf(“hello, world\n”); } }}} {{{#!cplusplus #include <stdio.h> /* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300 */ main () { int fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; while ( fahr <= upper) { celsius = 5 * (fahr - 32) / 9; printf( "%d\t%d\n", fahr, celsius); fahr = fahr + step; } } }}} {{{#!cplusplus #include <stdio.h> /* print Fahrenheit-Celsius table*/ main() { int fahr; for (fahr = 0; fahr <= 300; fahr = fahr + 20) printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32)); } }}} {{{1-1 Run the "hello, world" program on your system. Experiment with leaving out parts of the program, to see what error messages you get. }}} = 实验2-1 = == 实验目的 == |
|
行号 20: | 行号 122: |
= 实验2-2 = == 实验目的 == == 实验内容 == 写两个函数 * strcrop(s, i, j) 取字符串s中第i个到第j个字符 * strdel(s, i, j) 将字符串s中第i个到第j个字符删除 for example: {{{#!cplusplus char s[20]="hello world"; char t[20]="hello world"; strcrop(s, 1, 8); strdel(t, 1, 8); printf("%s\n%s\n", s, t); }}} output: {{{ ello wor hld }}} = 实验2-3 = == 实验目的 == 熟悉指针数组的使用 == 实验内容 == 写一个函数weekday(y,m,d),求取y年m月d日是星期几,返回星期几的名字。例如: {{{#!cplusplus printf("%s", weekday(2006,3,6)); }}}输出 {{{Monday }}} = 实验2-4 = == 实验目的 == 掌握多维数组的使用 == 实验内容 == 写一个函数{{{void inverse(int matrix[N][N])}}},将矩阵matrix转置。比如 {{{#!cplusplus #define N 3 int m[N][N] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; inverse(m); }}}得到结果: {{{ m = 1 4 7 2 5 8 3 6 9 }}} |
实验基本要求
- 实验前对实验内容做好预习
- 有效利用实验时间,不做与实验无关的活动
- 独立完成实验内容
- 按时提交实验报告
实验运行环境简介
1. DEV-C++集成开发环境
安装运行
- 运行安装程序进行安装
- 运行集成开发环境:开始菜单=〉Bloodshed Dev-C++ =〉Dev-C++
工程创建
在Dev-C++菜单中选择File=>New=>Project
- 在弹出对话框中选择Console Application,选中C Project,Name框输入一个工程名字,最后按OK按钮
- 选择硬盘上某个路径保存你所建立的工程
程序运行
选择菜单Execute=>Compile编译程序
如果编译没有错误,选择Execute=>Run运行程序,得到运行结果
如果程序结果一闪而过,怎么办?
- 在命令行窗口中运行可执行程序
- 在代码中添加:system("PAUSE");一行使程序暂停(system函数在stdlib.h中定义)
调试程序
- 启动调试
选择菜单Debug=>Debug
- 设置断点
将光标移动到需要设置断点的行,选择Debug=>Toggle Breakpoint
- 单步执行
菜单Debug=>Next Step和Step Into
- 查看变量
菜单Debug=>Add Watch
2. Visual Studio.Net 2003集成开发环境
创建工程
- 打开Visual Studio.net 2003集成开发环境
菜单File=>New=>Project
- 在弹出的对话框中:Project Types选择Visual C++ Projects,Templates选择Win32 Console Application,Name中输入工程名称,Location选择保存的路径。最后点OK
- 在接下来的工程向导中,选择Application Settings,选择Empty Project,最后按Finish
菜单View=>Solution Explorer
- 在Solution Explorer中选中刚才建立的工程
菜单File=>Add New Item
- 在弹出的对话框中:Categories选择Visual C++,Templates选择C++ File,Name中输入文件名,文件要以.c结尾,最后按Open。
编译运行
菜单Build=>Build Solution
如果编译通过,选择菜单Debug=>Start Without Debugging
调试
开始调试:菜单Debug=>Start
- 设置断点:光标移动到要设置断点的地方,按F9
- 单步执行:Debug菜单下的Step Into和Step Over
- 查看变量:Debug菜单下的Quick Watch
实验1-1
1. 实验目的
熟悉C语言开发环境,学会
- 创建工程
- 编辑代码
- 编译连接,生成可执行程序
- 调试代码
2. 实验内容
编译运行以下程序,观察程序运行的结果 完成课后作业1-1
1 #include <stdio.h>
2 /* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300 */
3 main ()
4 {
5 int fahr, celsius;
6 int lower, upper, step;
7 lower = 0;
8 upper = 300;
9 step = 20;
10 fahr = lower;
11 while ( fahr <= upper) {
12 celsius = 5 * (fahr - 32) / 9;
13 printf( "%d\t%d\n", fahr, celsius);
14 fahr = fahr + step;
15 }
16 }
{{{1-1 Run the "hello, world" program on your system. Experiment with leaving out parts of the program, to see what error messages you get. }}}
实验2-1
1. 实验目的
2. 实验内容
写一个函数strinsert(s, n, t)在字符串s的第n个字符后面插入字符串t。比如:
输出: {{{write once, run everywhere }}}
实验2-2
1. 实验目的
2. 实验内容
写两个函数
- strcrop(s, i, j) 取字符串s中第i个到第j个字符
- strdel(s, i, j) 将字符串s中第i个到第j个字符删除
for example:
output:
ello wor hld
实验2-3
1. 实验目的
熟悉指针数组的使用
2. 实验内容
写一个函数weekday(y,m,d),求取y年m月d日是星期几,返回星期几的名字。例如:
1 printf("%s", weekday(2006,3,6));
输出