只对了一个qwq
查看原帖
只对了一个qwq
749028
QAQ5楼主2024/12/28 16:34
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int q = Integer.parseInt(scanner.nextLine());
        String currentText = scanner.nextLine();
        for (int count = 0; count < q; count++) {
            String operate = scanner.nextLine();
            char operateCode = operate.charAt(0);
            String operateParameter = operate.substring(2);
            switch (operateCode) {
                case '1' -> {
                    currentText += operateParameter;
                    System.out.println(currentText);//1
                }
                case '2' -> {
                    String[] two = operateParameter.split(" ");//1
                    int a = Integer.parseInt(two[0]), b = Integer.parseInt(two[1]);
                    currentText = currentText.substring(a, a + b - 1);
                    System.out.println(currentText);//2
                }
                case '3' -> {
                    String[] two = operateParameter.split(" ");//2,两个重复了,咋省
                    int a = Integer.parseInt(two[0]);
                    String str = two[1];
                    String currentTextLeft = currentText.substring(0, a), currentTextRight = currentText.substring(a);
                    currentText = currentTextLeft + str + currentTextRight;
                    System.out.println(currentText);//3,这三个重复咋省略
                }
                case '4' -> {
                    System.out.println(currentText.indexOf(operateParameter));
                }
            }
        }
    }
}
2024/12/28 16:34
加载中...