中国电信笔试 中国电信秋招 中国电信笔试题 1025

笔试时间:2025年10月25日

往年笔试合集:

2023春招秋招笔试合集

2024春招秋招笔试合集

第一题

给你一个字母,你需要判断这个字母是大写还是小写,如果是大写,输出 "up",否则,输出 "low"。

输入描述

输入一行,一个单独的字符,保证是大写字母或者小写字母

输出描述

如果是大写字母,输出 "up",如果是小写字母,输出 "low"。

样例输入

A

样例输出

up

参考题解

利用字符的 ASCII 码范围判断:大写字母的 ASCII 码在 65('A')~90('Z') 之间,小写字母在 97('a')~122('z') 之间。读取字符后,判断其是否属于大写字母范围即可。

C++:

#include <iostream>
using namespace std;

int main() {
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') {
        cout << "up" << endl;
    } else {
        cout << "low" << endl;
    }
    return 0;
}

Java:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char c = in.next().charAt(0);
        if (c >= 'A' && c <= 'Z') {
            System.out.println("up");
        } else {
            System.out.println("low");
        }
    }
}

Python:

c = input()
if 'A' <= c <= 'Z':
    print("up")
else:
    print("low")

第二题

输入一个字符串 s,其要么是 "min",要么是 "max",随后输入两个整数 x, y:

  • 如果 s 是 "min",则输出 x 和 y 中的较小值;
  • 如果 s 是 "max",则输出 x 和 y 中的较大值。

输入描述

第一行输入一个长度为 3 的字符串 s,保证其为 "min" 或 "max"。 第二行输入两个整数 x, y(-10 ≤ x, y ≤ 10)。

输出描述

输出一个整数,表示 x 和 y 中的较小值或较大值。

样例输入

min

0 0

样例输出

0

参考题解

解题思路: 读取字符串 s,判断其是 "min" 还是 "max"。读取两个整数 x 和 y。根据 s 的类型,使用 min 或 max 函数计算并输出结果。

C++:

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    if (s == "min") {
        cout << min(x, y) << endl;
    } else {
        cout << max(x, y) << endl;
    }
    return 0;
}

Java:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int x = in.nextInt();
        int y = in.nextInt();
        if (s.equals("min")) {
            System.out.println(Math.min(x, y));
        } else {
            System.out.println(Math.max(x, y));
        }
        in.close();
    }
}

Python:

s = input()
x, y = map(int, input().split())
if s == "min":
    print(min(x, y))
else:
    print(max(x, y))

第三题

Alice 与 Bob 进行n回合

剩余60%内容,订阅专栏后可继续查看/也可单篇购买

2025 春招笔试合集 文章被收录于专栏

2025打怪升级记录,大厂笔试合集 C++, Java, Python等多种语言做法集合指南

全部评论

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务