aiaiask.com©

开花即结果 提问即答案

"Java实现外卖送达时间超时判断算法"
原始问题:

"Java实现外卖送达时间超时判断算法"

以下是用Java语言实现该算法的示例代码:

import java.util.Scanner;

public class DeliveryTime {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt(); // 询问次数

        for (int i = 0; i < t; i++) {
            int t1 = scanner.nextInt(); // 点外卖的时刻t1
            int t2 = scanner.nextInt(); // 预计送达时间t2
            int t3 = scanner.nextInt(); // 实际送达时间t3

            if (t3 - t1 > t2) {
                System.out.println("是"); // 超时
            } else {
                System.out.println("否"); // 未超时
            }
        }
    }
}

使用该算法,您可以按照以下格式输入数据:

3
10
30
25
15
20
18
5
10
12

输出结果将会是:

否
否
是

希望这个示例代码能够帮助到您!如果您有任何其他问题,请随时提问。

"Java实现外卖送达时间超时判断算法"
https://www.aiaiask.com/ask/44755.html
AI / 模型Siliconflow
时间 / DATEAugust 17, 2023, 7:44 PM
语言zh-CN
IP / 区域安徽 合肥