import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String choice = scanner.next();
System.out.println("choice=" + choice);
if (choice.equals("double")) {
double a, b, c;
a = scanner.nextDouble();
b = scanner.nextDouble();
c = scanner.nextDouble();
System.out.printf("%-5.2f,%5.2f,%.2f\n", a, b, c);
} else if (choice.equals("int")) {
int a, b, c;
a = scanner.nextInt();
b = scanner.nextInt();
c = scanner.nextInt();
System.out.println(a + b + c);
} else if (choice.equals("str")) {
scanner.nextLine();
String str = scanner.nextLine();
String[] arr = str.split("\\s+");
//首先要明白split方法的参数含义:
//split
//public String[] split(String regex)根据给定的正则表达式的匹配来拆分此字符串。
//然后就要明确正则表达式的含义了:
//\\s表示 空格,回车,换行等空白符,
//+号表示一个或多个的意思,所以...
for (int i = 2; i >= 0; i--) {
System.out.print(arr[i]);
}
System.out.println();
} else if (choice.equals("line")) {
scanner.nextLine();
String str = scanner.nextLine();
System.out.println(str.toUpperCase());
//str.toUpperCase()函数将整个字符串转换为大写。
} else {
System.out.println("other");
}
}
}
}
scanner.nextLine();的目的是,在读取完str以后,跳过一行,再读取3行字符串,为什么要跳过一行,是因为你之前用的是 scanner.next() 读取了 str,缓冲区里还有一个换行符,然后才是下面输入的字符串。
常见的路由选择协议有: RIP 协议、 OSPF 协议。
RIP 协议 :底层是贝尔曼福特算法,它选择路由的度量标准( metric) 是跳数,最大跳数是 15 跳,如果大于 15 跳,它就会丢弃数据包。
OSPF 协议 :底层是迪杰斯特拉算法,是链路状态路由选择协议,它选择路由的度量标准是带宽,延迟。
答:很抱歉,以上参考资料中并没有与你所提到的代码和红色标注相关的内容,因此无法给出解决方案。请提供更详细的信息或参考资料,我将尽力为您解答。