```java import java.util.Scanner; public class PetRobotVirusFixer { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // 读取第一行输入,处理第一种感染方式 String firstInfected = scanner.nextLine(); String firstFixed = fixFirstInfection(firstInfected); // 读取第二行输入,处理第二种感染方式 String secondInfected = scanner.nextLine(); String secondFixed = fixSecondInfection(secondInfected); // 输出修复后的结果 System.out.println(firstFixed + "," + secondFixed); } // 处理第一种感染方式:移除括号外的所有数字 private static String fixFirstInfection(String infected) { int start = infected.indexOf('('); int end = infected.indexOf(')'); if (start != -1 && end != -1) { return infected.substring(start + 1, end); } return infected; } // 处理第二种感染方式:移除单词中的“...” private static String fixSecondInfection(String infected) { return infected.replace("...", ""); } } ``` 额外需要注意的逻辑点: 1. 边界条件处理:确保输入的字符串中确实包含括号或“...”,如果不存在这些字符,直接返回原字符串。 2. 异常处理:考虑输入字符串格式不正确的情况,比如括号不匹配或缺少括号。 3. 性能优化:对于较长的字符串,可以使用 `StringBuilder` 来提高字符串拼接的效率。 [2024-12-07 18:17:04 | AI写代码神器 | 341点数解答]