s(取值为 "min" 或 "max")以及两个整数 x、y。s == "min",输出 min(x, y);否则("max")输出 max(x, y)。min/max 函数实现。# 功能函数:根据指令返回最小或最大值
def solve(s: str, x: int, y: int) -> int:
# 根据题意选择 min 或 max
return min(x, y) if s == "min" else max(x, y)
if __name__ == "__main__":
# ACM 风格输入:三段数据,分别是 s、x、y
import sys
tokens = sys.stdin.read().strip().split()
s = tokens[0]
x = int(tokens[1])
y = int(tokens[2])
# 输出结果
print(solve(s, x, y))
import java.util.*;
// ACM 风格主类名固定为 Main
public class Main {
// 功能函数:根据指令返回最小或最大值
public static int solve(String s, int x, int y) {
if ("min".equals(s)) return Math.min(x, y);
else return Math.max(x, y); // s 保证为 "max"
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 读入:字符串 s 与两个整数 x、y
String s = sc.next();
int x = sc.nextInt();
int y = sc.nextInt();
// 输出结果
System.out.print(solve(s, x, y));
sc.close();
}
}
#include <bits/stdc++.h>
using namespace std;
// 功能函数:根据指令返回最小或最大值
int solve(const string& s, int x, int y) {
if (s == "min") return std::min(x, y);
else return std::max(x, y); // s 保证为 "max"
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// 读入:字符串 s 与两个整数 x、y
string s;
int x, y;
cin >> s >> x >> y;
// 输出结果
cout << solve(s, x, y);
return 0;
}
输入一个字符串 s,其要么是" min ",要么是" max",随后输入两个整数 “,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",所以输出 x 和 y 中的较小值,即 0
输入
max
-1 3
输出
3