# 实验课基本要求

• 实验课前对实验内容做好预习
• 有效利用实验课时间，不做与实验无关的活动
• 独立完成实验内容
• 按时提交实验报告，发送到 [email protected]

• 实验报告模板：

• [get | view] (2018-11-13 20:25:53, 110.5 KB) [[attachment:高级语言程序设计.doc]]
All files | Selected Files: delete move to page copy to page

# 实验1-1

• 创建工程
• 编辑代码
• 编译连接，生成可执行程序
• 调试代码

## 2. 实验内容

```   1 #include <stdio.h>
2 main()
3 {
4         printf("hello, world\n");
5 }
```

```   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 #include <stdio.h>
2 /* print Fahrenheit-Celsius table*/
3 main()
4 {
5     int fahr;
6
7     for (fahr = 0; fahr <= 300; fahr = fahr + 20)
8         printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
9 }
```

{{{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. }}}

# 实验1-2

## 1. 实验目的

• 掌握C语言变量、循环的基本概念
• 掌握基本的算术运算

## 2. 实验内容

• Write a program to print the corresponding Celsius to Fahrenheit table.
• Modify the temperature conversion program to print the table in reverse order, that is, from 300 degrees to 0.

# 实验1-3

## 2. 实验目的

• 掌握C语言函数的基本概念
• 掌握C语言函数的定义和调用方法
• 理解C语言字符串和字符数组的使用方法

# 实验1-5

## 1. 实验目的

• 掌握关系表达式和IF语句
• 掌握循环的使用方法
• 巩固C语言数组、字符串的使用方法

## 2. 实验内容

Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time.

# 实验1-6

## 2. 实验内容

Write a version of itoa that accepts three arguments instead of two. The third argument is a minimum field width; the converted number must be padded with banks on the left if necessary to make it wide enough.

# 实验1-7

• 掌握全局变量使用方法
• 掌握多文件的组织方法

## 2. 实验内容

Exercise 4-3. Given the basic framework, it's straightforward to extend the calculator. Add the modulus (%) operator.

# 实验1-8

## 2. 实验内容

Write a recursive version of the function reverse(s), which reverses the string s in place.

# 实验1-9

## 1. 实验内容

```   1 main()
2 {
3     push(1);
4     push(2);
5     push(3);
6     printf("size:%d\n", size() );
7     printf("top:%f\n", top() );
8     printf("stack is%s empty\n", (empty() ?"":" not" ));
9     printf("content: ");
10     print();
11     printf("\n");
12     clear();
13     printf("size:%d\n", size());
14     printf("stack is%s empty\n", (empty() ?"":" not" ));
15 }
```

# 实验1-10

## 1. 实验内容

C语言课程实验 (last edited 2008-02-23 15:36:56 by localhost)

ch3n2k.com | Copyright (c) 2004-2022 czk.