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

1.4 KiB
Raw Blame History

title
2025-2026学年春季期期中(whq)

一、选择20 分) 10道

函数可以没有返回值

实参形参必须完全一致

函数里不允许嵌套定义函数

二、填空20 分)

  1. 静态变量关键词____常态变量关键词____

  2. #include<stdio.h>
    int main() {
        int a = 3, b = 2;
        float c = 3 * 5 / b;
        printf("%.2f",c);
    }
    

    ____

  3. a = 9, b = 2!(a * 2 % 4) && (c = 2) || (7 - 2 * b > 2) 输出____

  4. unsigned int 取值多少 ____

  5. short arr[11]; 占用____ bit(s)

三、判断输出20 分)

  1. #include<stdio.h>
    int main() {
      int row = 3, col = 4, i, j;
      for(i = 0; i < row; i++) {
        printf("#");
        for(j = 0; j < col; j ++) {
          if(i == j) break;
          if(i == col - j) continue;
          printf("*");
        }
        printf("\n");
      }
      return 0;
    }
    
  2. #include<stdio.h>
    #define SQUARE(x) x*x
    int main() {
      int a = 5;
      int b = SQUARE(a + 1);
      printf("SQUARE(a+1):%d",b);
      return 0;
    }
    

四、手写代码40 分)

  1. 求五个数中的中位数

    Input

    5 2 4 3 1

    Output

    3

  2. 100~999 的素数水仙花数,如果没有,输出No Such Number.

    Input

    Output

    No Such Number.