首页 › 题库 › GESP编程能力等级认证 › 1.3 TCP/IP与OSI

GESP-C++二级 题库

共 4 道题 · 按题型筛选,点「查看答案」核对解析
章节 1.3 TCP/IP与OSI 清除
1 单选题 适中 GESP编程能力等级认证 ·GESP-C++二级 · 1.3 TCP/IP与OSI

在TCP协议中,完成连接建立需要通过( )握手。2025.9-2C

A

一次

B

二次

C

三次

D

四次

答案与解析
正确答案:C
这道题暂未补解析。
题目详情
2 判断题 偏易 GESP编程能力等级认证 ·GESP-C++二级 · 1.3 TCP/IP与OSI

IPv4 的地址通常用“点分十进制”的表示形式,形如(a.b.c.d),其中a、b、c、d 都是 1~255 之间的十进制整数( )。

A
对
B
错
答案与解析
正确答案:错
这道题暂未补解析。
题目详情
3 简答题 偏难 GESP编程能力等级认证 ·GESP-C++二级 · 1.3 TCP/IP与OSI

优美的数字

答案与解析
参考答案
#include <algorithm>
#include <cstdio>
using namespace std;

int n, ans = 0;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int v = i % 10;
    int t = i / 10;
    int chk = 1;
    while (t) {
      if (t % 10 != v) {
        chk = 0;
        // 找到不同数字可以直接跳出循环,优化
        break;
      }
      t /= 10;
    }
    ans += chk;
  }
  printf("%d\n", ans);
  return 0;
}
题目详情
4 简答题 偏难 GESP编程能力等级认证 ·GESP-C++二级 · 1.3 TCP/IP与OSI

菱形

答案与解析
参考答案
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
    int n, i, j, k;
    scanf("%d", &n);
    k = n / 2;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            // 曼哈顿距离等于k时输出#,否则.
            if (abs(k - i + 1) + abs(k - j + 1) == k)
                printf("#");
            else
                printf(".");
        }
        printf("\n");
    }
    return 0;
}
题目详情