SharedCourses/docs/undergraduate/软件工程学院/程序设计基础/2025-2026-1_期中_张泉.md

129 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 2025-2026学年春季期期中(张泉)
---
## 一、判断16 分)
1. 变量定义可以数字开头
2. C 语言是面向过程的语言
3. `(x % 2 == 0) && (6 <= x <= 10)` 表示 $[6,10]$ 的偶数
4. 不符合逻辑顺序的代码如果代码紧凑,则符合书写规范(大意如此)
5. 假定 `a, b``double` 类型。`printf("%lf", (a = 2, b = a + 3 / 2))` 输出是 `3.000000`
## 二、读代码25 分)
1. a=\_\_\_\_
```c
#include<stdio.h>
int main() {
int a = 3, b = 4;
a += b *= a + b;
printf("a=%d", a);
}
```
2. a=\_\_\_\_<br></br>a=\_\_\_\_
```c
#include<stdio.h>
void Anaesthesia(int b) {
static int a = 0;
a += b;
printf("a=%d\n", a);
}
int main() {
Anaesthesia(5);
Anaesthesia(5);
}
```
3. \_\_\_\_, \_\_\_\_
```c
#include<stdio.h>
int main() {
c = 'A' + 4 - 'Z' + 'z';
d = 'A' + '8' - '5';
printf("%c %d", c, d);
}
```
4. \_\_\_\_, \_\_\_\_
```c
#include<stdio.h>
int main() {
int a = 2;
char b;
double Pi = 3.14;
printf("%d %lf", sizeof(a*b), Pi+8/3);
}
```
5. \_\_\_\_
```c
#include<stdio.h>
int main() {
int a = 5, b = 10, c = 15;
if((a -= 5) || (b = a) && (c -= 1)) {
c += 5;
} else {
c -= 5;
}
printf("%d", c);
}
```
## 三、选择题25分题面暂缺
函数不允许嵌套定义函数(函数里不可以定义函数)
编译成功一定运行一定成功
变量定义是下划线、字母、数字随意组合
3. 正确的是()
A. `char` 可以取余
B. `(a = 3, b = 5, a + b)` 的值是 $3$
C. `i++``++i` 任何情况下都一样
D. 赋值运算符优先级高于所有基本运算符
## 四、手写代码35 分)
1. 定义一个常量 $E=2.71828$ 输出 $E^3$ (保留五位小数)
**Input**
>
**Output**
> `20.08553`
2. 给入一个值 `n` 打出表格
**Input**
> `4`
**Output**
> ```text
> ***#
> **#*
> *#**
> #***
> ```
3. 输入一个字母,小写转大写,大写转小写
**Input**
> `a`
**Output**
> `A`