原始问题:
"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输出结果将会是:
否
否
是希望这个示例代码能够帮助到您!如果您有任何其他问题,请随时提问。
Prev:妈妈生气因饮食不规律 矛盾程度若量化会是多少